MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / TestWait

Function TestWait

pkg/cmd/task/wait/wait_test.go:22–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20var rootResource = testutil.NewRootResource()
21
22func TestWait(t *testing.T) {
23 out := bytes.Buffer{}
24 defaultTaskIDs := []string{
25 "TaskID1",
26 "TaskID2",
27 }
28
29 taskList := []*tasks.Task{
30 tasks.NewTask(),
31 tasks.NewTask(),
32 }
33
34 // bool vars as bool constants can't be used as pointers for IsCompleted
35 boolFalse := false
36 boolTrue := true
37
38 taskList[0].ID = defaultTaskIDs[0]
39 taskList[0].IsCompleted = &boolFalse
40 taskList[0].FinishedSuccessfully = &boolFalse
41 taskList[0].Description = "Deploy Bar 1 release 0.0.2 to Foo"
42 taskList[0].State = "Executing"
43
44 taskList[1].ID = defaultTaskIDs[1]
45 taskList[1].IsCompleted = &boolTrue
46 taskList[1].FinishedSuccessfully = &boolTrue
47 taskList[1].Description = "Deploy Bar 2 release 0.0.2 to Foo"
48 taskList[1].State = "Success"
49
50 timesCalled := 0
51
52 getServerTaskCallback := func(taskIDs []string) ([]*tasks.Task, error) {
53 timesCalled += 1
54 switch timesCalled {
55 case 1:
56 assert.Len(t, taskIDs, 2)
57 assert.Equal(t, defaultTaskIDs[0], taskIDs[0])
58 assert.Equal(t, defaultTaskIDs[1], taskIDs[1])
59 return taskList, nil
60 case 2:
61 assert.Len(t, taskIDs, 1)
62 assert.Equal(t, defaultTaskIDs[0], taskIDs[0])
63 taskList[0].IsCompleted = &boolTrue
64 taskList[0].FinishedSuccessfully = &boolTrue
65 taskList[0].State = "Success"
66 taskList = taskList[:len(taskList)-1]
67 return taskList, nil
68 }
69 return nil, fmt.Errorf("getServerTaskCallback was called more then the expected amount of times")
70 }
71
72 opts := &taskWaitCreate.WaitOptions{
73 Dependencies: &cmd.Dependencies{
74 Out: &out,
75 },
76 TaskIDs: defaultTaskIDs,
77 GetServerTasksCallback: getServerTaskCallback,
78 GetTaskDetailsCallback: nil,
79 Timeout: taskWaitCreate.DefaultTimeout,

Callers

nothing calls this directly

Calls 1

LenMethod · 0.80

Tested by

no test coverage detected