This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
/
mock_closures.go
67 lines (59 loc) · 1.55 KB
/
mock_closures.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
// Provides sample closures for use in tests.
package testutils
import (
"time"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
)
var MockCreatedAtValue = time.Date(2018, time.February, 17, 00, 00, 00, 00, time.UTC).UTC()
var MockCreatedAtProto, _ = ptypes.TimestampProto(MockCreatedAtValue)
func GetTaskClosure() *admin.TaskClosure {
return &admin.TaskClosure{
CompiledTask: &core.CompiledTask{
Template: GetValidTaskRequest().Spec.Template,
},
CreatedAt: MockCreatedAtProto,
}
}
func GetTaskClosureBytes() []byte {
var taskClosureBytes, _ = proto.Marshal(GetTaskClosure())
return taskClosureBytes
}
func GetWorkflowClosure() *admin.WorkflowClosure {
return &admin.WorkflowClosure{
CompiledWorkflow: &core.CompiledWorkflowClosure{
Primary: &core.CompiledWorkflow{
Template: GetWorkflowRequest().Spec.Template,
},
Tasks: []*core.CompiledTask{
{
Template: GetValidTaskRequest().Spec.Template,
},
},
},
CreatedAt: MockCreatedAtProto,
}
}
func GetWorkflowClosureBytes() []byte {
// WorkflowClosure
var workflowClosureBytes, _ = proto.Marshal(GetWorkflowClosure())
return workflowClosureBytes
}
func MakeStringLiteral(value string) *core.Literal {
p := &core.Primitive{
Value: &core.Primitive_StringValue{
StringValue: value,
},
}
return &core.Literal{
Value: &core.Literal_Scalar{
Scalar: &core.Scalar{
Value: &core.Scalar_Primitive{
Primitive: p,
},
},
},
}
}