# How to test timeouts?

**URL:** <https://community.temporal.io/t/how-to-test-timeouts/1781>\
**Category:** Community Support\
**Tags:** go-sdk, testing\
**Created:** [March 21, 2021, 9:35pm UTC](https://community.temporal.io/t/how-to-test-timeouts/1781 "2021-03-21T21:35:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paolosoto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/paolosoto/32/829_2.png) [@paolosoto](https://community.temporal.io/u/paolosoto)\
**Post date:** [March 21, 2021, 9:35pm UTC](https://community.temporal.io/t/how-to-test-timeouts/1781/1 "2021-03-21T21:35:57Z")

</div>

Hi!

Im trying to test activities timeouts, but i don’t understand how works **RegisterDelayedCallback** :

### My Workflow

```
func ExamWorkflow(ctx workflow.Context, examID string) (string, error) {

	logger := workflow.GetLogger(ctx)

	logger.Info("Starting workflow for exam ", examID)

	// pass exam to AWAITING_EXAM status
	ao := workflow.ActivityOptions{
		ScheduleToStartTimeout: 1 * time.Minute,
		StartToCloseTimeout: 1 * time.Minute,
		HeartbeatTimeout: 1 * time.Minute,
		ScheduleToCloseTimeout: 1 * time.Minute,
	}
	ctxAe := workflow.WithActivityOptions(ctx, ao)
	var res string
	err := workflow.ExecuteActivity(ctxAe, AwaitingExamActivity, examID).Get(ctxAe, &res)
	if err != nil {
		logger.Error("failed awaiting exam %s : %s", examID, err)
		return "", err
	}

	err = workflow.ExecuteActivity(ctxAe, ExamInProgressActivity, examID).Get(ctxAe, &res)
	if err != nil {
		logger.Error("failed inprogress exam %s : %s", examID, err)
		return "", err
	}

	logger.Info("Finishing workflow for exam %s", examID)

	return "", nil
}

```

### My Activities

```
func AwaitingExamActivity(ctx context.Context, examID string) (string, error) {

	log := activity.GetLogger(ctx)
	activityInfo := activity.GetInfo(ctx)
	taskToken := activityInfo.TaskToken

	ioutil.WriteFile("./token.txt", taskToken, 0644)

	log.Info("Estado espera", "Valor token", string(taskToken))
	log.Info("Puts exam " + examID + " in AWAITING_EXAM status and takes a number for attention")

	return "", activity.ErrResultPending

}

// ExamInProgressActivity - Puts exam in EXAM_IN_PROGRESS status.
func ExamInProgressActivity(ctx context.Context, examID string) error {

	log := activity.GetLogger(ctx)
	log.Info("Puts exam ", examID, " in EXAM_IN_PROGRESS status and takes a number for attention")

	activityInfo := activity.GetInfo(ctx)
	taskToken := activityInfo.TaskToken

	ioutil.WriteFile("./token_eip.txt", taskToken, 0644)

	return activity.ErrResultPending

}

```

### Test

```
func (s *UnitTestSuite) Test_Workflow() {

	env := s.NewTestWorkflowEnvironment()

	env.RegisterDelayedCallback(func() {
		token, err := ioutil.ReadFile("./token.txt")
		if err != nil {
			log.Fatal(err)
		}
		log.Println("en espera")
		env.CompleteActivity(token, "", nil)
	}, 10*time.Minute)

	env.RegisterActivity(AwaitingExamActivity)

	env.RegisterDelayedCallback(func() {
		token, err := ioutil.ReadFile("./token_eip.txt")
		if err != nil {
			log.Fatal(err)
		}
		log.Println("en espera")
		env.CompleteActivity(token, "", nil)
	}, 10*time.Minute)

	env.RegisterActivity(ExamInProgressActivity)

	env.ExecuteWorkflow(ExamWorkflow, "45")

	s.True(env.IsWorkflowCompleted())
	err := env.GetWorkflowResult(nil)
	s.NoError(err)

}

```

The ActivityOptions has one minute in timeout for all their attributes and the callbacks has ten minutes, but the test finish ok.

Can anyone explain me why has this behaviour?

Thanks.

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [March 24, 2021, 7:05pm UTC](https://community.temporal.io/t/how-to-test-timeouts/1781/2 "2021-03-24T19:05:23Z")

</div>

It looks like a bug in the unit testing framework. Would you file an issue to get this looked at?

---

<div class="post-metadata">

**Author:** ![paolosoto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/paolosoto/32/829_2.png) [@paolosoto](https://community.temporal.io/u/paolosoto)\
**Post date:** [March 31, 2021, 8:08pm UTC](https://community.temporal.io/t/how-to-test-timeouts/1781/3 "2021-03-31T20:08:41Z")

</div>

> [@maxim](#):
>
> Would you file an issue to get this looked at?

oh! thanks for the answer. Ok, i will report this case. Regards.
