forked from metalsoft-io/metalcloud-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_workflows_test.go
77 lines (61 loc) · 1.44 KB
/
cmd_workflows_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package main
import (
"testing"
metalcloud "github.com/metalsoft-io/metal-cloud-sdk-go/v2"
mock_metalcloud "github.com/metalsoft-io/metalcloud-cli/helpers"
gomock "github.com/golang/mock/gomock"
. "github.com/onsi/gomega"
)
func TestWorkflowsGetCmd(t *testing.T) {
RegisterTestingT(t)
ctrl := gomock.NewController(t)
client := mock_metalcloud.NewMockMetalCloudClient(ctrl)
wf := metalcloud.Workflow{
WorkflowID: 10,
WorkflowLabel: "test",
WorkflowDescription: "asdsd",
}
vtList := map[string]metalcloud.Workflow{
"test": wf,
"test2": wf,
}
client.EXPECT().
Workflows().
Return(&vtList, nil).
AnyTimes()
client.EXPECT().
WorkflowGet(10).
Return(&wf, nil).
AnyTimes()
stageDef := metalcloud.StageDefinition{
StageDefinitionID: 10,
StageDefinitionLabel: "test",
StageDefinitionTitle: "Test",
}
client.EXPECT().
StageDefinitionGet(30).
Return(&stageDef, nil).
AnyTimes()
stages := []metalcloud.WorkflowStageDefinitionReference{
{
WorkflowStageID: 103,
WorkflowID: 10,
StageDefinitionID: 30,
WorkflowStageRunLevel: 1,
},
}
client.EXPECT().
WorkflowStages(10).
Return(&stages, nil).
AnyTimes()
format := "json"
cmd := Command{
Arguments: map[string]interface{}{
"format": &format,
"workflow_id_or_label": &wf.WorkflowID,
},
}
ret, err := workflowGetCmd(&cmd, client)
Expect(err).To(BeNil())
Expect(ret).ToNot(BeNil())
}