@@ -13,81 +13,42 @@ import (
13
13
"github.com/golang/protobuf/ptypes/empty"
14
14
"github.com/stretchr/testify/assert"
15
15
"github.com/stretchr/testify/mock"
16
+ "google.golang.org/grpc"
16
17
"k8s.io/apimachinery/pkg/apis/meta/v1"
17
18
k8stypes "k8s.io/apimachinery/pkg/types"
18
19
)
19
20
20
- type mockInvocationServer struct {
21
+ type mockWorkflowClient struct {
21
22
mock.Mock
22
23
}
23
24
24
- func (m * mockInvocationServer ) Invoke (ctx context.Context , spec * types.WorkflowInvocationSpec ) (* types.ObjectMetadata , error ) {
25
- args := m .Called (spec )
26
- id := spec .WorkflowId
27
- if len (id ) == 0 {
28
- id = "randomUID"
29
- }
30
- return & types.ObjectMetadata {Id : args .String (0 )}, args .Error (1 )
31
- }
32
-
33
- func (m * mockInvocationServer ) InvokeSync (ctx context.Context , spec * types.WorkflowInvocationSpec ) (* types.
34
- WorkflowInvocation , error ) {
35
- args := m .Called (spec )
36
- return args .Get (0 ).(* types.WorkflowInvocation ), args .Error (1 )
37
- }
38
-
39
- func (m * mockInvocationServer ) Cancel (ctx context.Context , id * types.ObjectMetadata ) (* empty.Empty , error ) {
40
- args := m .Called (id )
41
- return & empty.Empty {}, args .Error (1 )
42
- }
43
-
44
- func (m * mockInvocationServer ) List (ctx context.Context , _ * apiserver.InvocationListQuery ) (* apiserver.WorkflowInvocationList , error ) {
45
- args := m .Called ()
46
- return args .Get (0 ).(* apiserver.WorkflowInvocationList ), args .Error (1 )
47
- }
48
-
49
- func (m * mockInvocationServer ) Get (ctx context.Context , id * types.ObjectMetadata ) (* types.
50
- WorkflowInvocation , error ) {
51
- args := m .Called (id )
52
- return args .Get (0 ).(* types.WorkflowInvocation ), args .Error (1 )
53
- }
54
-
55
- func (m * mockInvocationServer ) Validate (ctx context.Context , spec * types.WorkflowInvocationSpec ) (* empty.Empty , error ) {
56
- args := m .Called (spec )
57
- return & empty.Empty {}, args .Error (1 )
58
- }
59
-
60
- type mockWorkflowServer struct {
61
- mock.Mock
62
- }
63
-
64
- func (m * mockWorkflowServer ) Create (ctx context.Context , spec * types.WorkflowSpec ) (* types.ObjectMetadata , error ) {
65
- args := m .Called (spec )
25
+ func (m * mockWorkflowClient ) Create (ctx context.Context , in * types.WorkflowSpec , opts ... grpc.CallOption ) (* types.ObjectMetadata , error ) {
26
+ args := m .Called (in )
66
27
return & types.ObjectMetadata {Id : args .String (0 )}, args .Error (1 )
67
28
}
68
29
69
- func (m mockWorkflowServer ) List (ctx context.Context , _ * empty.Empty ) (* apiserver.WorkflowList , error ) {
30
+ func (m * mockWorkflowClient ) List (ctx context.Context , in * empty.Empty , opts ... grpc. CallOption ) (* apiserver.WorkflowList , error ) {
70
31
args := m .Called ()
71
32
return args .Get (0 ).(* apiserver.WorkflowList ), args .Error (1 )
72
33
}
73
34
74
- func (m mockWorkflowServer ) Get (ctx context.Context , id * types.ObjectMetadata ) (* types.Workflow , error ) {
75
- args := m .Called (id )
35
+ func (m * mockWorkflowClient ) Get (ctx context.Context , in * types.ObjectMetadata , opts ... grpc. CallOption ) (* types.Workflow , error ) {
36
+ args := m .Called (in )
76
37
return args .Get (0 ).(* types.Workflow ), args .Error (1 )
77
38
}
78
39
79
- func (m mockWorkflowServer ) Delete (ctx context.Context , id * types.ObjectMetadata ) (* empty.Empty , error ) {
80
- args := m .Called (id )
40
+ func (m * mockWorkflowClient ) Delete (ctx context.Context , in * types.ObjectMetadata , opts ... grpc. CallOption ) (* empty.Empty , error ) {
41
+ args := m .Called (in )
81
42
return & empty.Empty {}, args .Error (1 )
82
43
}
83
44
84
- func (m mockWorkflowServer ) Validate (ctx context.Context , spec * types.WorkflowSpec ) (* empty.Empty , error ) {
85
- args := m .Called (spec )
45
+ func (m * mockWorkflowClient ) Validate (ctx context.Context , in * types.WorkflowSpec , opts ... grpc. CallOption ) (* empty.Empty , error ) {
46
+ args := m .Called (in )
86
47
return & empty.Empty {}, args .Error (1 )
87
48
}
88
49
89
50
func TestProxy_Specialize (t * testing.T ) {
90
- workflowServer := & mockWorkflowServer {}
51
+ workflowServer := & mockWorkflowClient {}
91
52
workflowServer .On ("Create" , mock .Anything ).Return ("mockID" , nil )
92
53
env := NewEnvironmentProxyServer (nil , workflowServer )
93
54
wf := & types.WorkflowSpec {
0 commit comments