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 62
/
node_execution_repo.go
123 lines (102 loc) · 4.32 KB
/
node_execution_repo.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package mocks
import (
"context"
"github.com/flyteorg/flyteadmin/pkg/repositories/interfaces"
"github.com/flyteorg/flyteadmin/pkg/repositories/models"
)
type CreateNodeExecutionFunc func(ctx context.Context, input *models.NodeExecution) error
type UpdateNodeExecutionFunc func(ctx context.Context, nodeExecution *models.NodeExecution) error
type GetNodeExecutionFunc func(ctx context.Context, input interfaces.NodeExecutionResource) (models.NodeExecution, error)
type ListNodeExecutionFunc func(ctx context.Context, input interfaces.ListResourceInput) (
interfaces.NodeExecutionCollectionOutput, error)
type ListNodeExecutionEventFunc func(ctx context.Context, input interfaces.ListResourceInput) (
interfaces.NodeExecutionEventCollectionOutput, error)
type ExistsNodeExecutionFunc func(ctx context.Context, input interfaces.NodeExecutionResource) (bool, error)
type CountNodeExecutionFunc func(ctx context.Context, input interfaces.CountResourceInput) (int64, error)
type MockNodeExecutionRepo struct {
createFunction CreateNodeExecutionFunc
updateFunction UpdateNodeExecutionFunc
getFunction GetNodeExecutionFunc
getWithChildrenFunction GetNodeExecutionFunc
listFunction ListNodeExecutionFunc
listEventFunction ListNodeExecutionEventFunc
existsFunction ExistsNodeExecutionFunc
countFunction CountNodeExecutionFunc
}
func (r *MockNodeExecutionRepo) Create(ctx context.Context, input *models.NodeExecution) error {
if r.createFunction != nil {
return r.createFunction(ctx, input)
}
return nil
}
func (r *MockNodeExecutionRepo) SetCreateCallback(createFunction CreateNodeExecutionFunc) {
r.createFunction = createFunction
}
func (r *MockNodeExecutionRepo) Update(ctx context.Context, nodeExecution *models.NodeExecution) error {
if r.updateFunction != nil {
return r.updateFunction(ctx, nodeExecution)
}
return nil
}
func (r *MockNodeExecutionRepo) SetUpdateCallback(updateFunction UpdateNodeExecutionFunc) {
r.updateFunction = updateFunction
}
func (r *MockNodeExecutionRepo) Get(ctx context.Context, input interfaces.NodeExecutionResource) (models.NodeExecution, error) {
if r.getFunction != nil {
return r.getFunction(ctx, input)
}
return models.NodeExecution{}, nil
}
func (r *MockNodeExecutionRepo) SetGetCallback(getFunction GetNodeExecutionFunc) {
r.getFunction = getFunction
}
func (r *MockNodeExecutionRepo) GetWithChildren(ctx context.Context, input interfaces.NodeExecutionResource) (models.NodeExecution, error) {
if r.getWithChildrenFunction != nil {
return r.getWithChildrenFunction(ctx, input)
}
return models.NodeExecution{}, nil
}
func (r *MockNodeExecutionRepo) SetGetWithChildrenCallback(getWithChildrenFunction GetNodeExecutionFunc) {
r.getWithChildrenFunction = getWithChildrenFunction
}
func (r *MockNodeExecutionRepo) List(ctx context.Context, input interfaces.ListResourceInput) (
interfaces.NodeExecutionCollectionOutput, error) {
if r.listFunction != nil {
return r.listFunction(ctx, input)
}
return interfaces.NodeExecutionCollectionOutput{}, nil
}
func (r *MockNodeExecutionRepo) SetListCallback(listFunction ListNodeExecutionFunc) {
r.listFunction = listFunction
}
func (r *MockNodeExecutionRepo) ListEvents(ctx context.Context, input interfaces.ListResourceInput) (
interfaces.NodeExecutionEventCollectionOutput, error) {
if r.listFunction != nil {
return r.listEventFunction(ctx, input)
}
return interfaces.NodeExecutionEventCollectionOutput{}, nil
}
func (r *MockNodeExecutionRepo) SetListEventCallback(listEventFunction ListNodeExecutionEventFunc) {
r.listEventFunction = listEventFunction
}
func (r *MockNodeExecutionRepo) Exists(ctx context.Context, input interfaces.NodeExecutionResource) (bool, error) {
if r.existsFunction != nil {
return r.existsFunction(ctx, input)
}
return true, nil
}
func (r *MockNodeExecutionRepo) SetExistsCallback(existsFunction ExistsNodeExecutionFunc) {
r.existsFunction = existsFunction
}
func (r *MockNodeExecutionRepo) Count(ctx context.Context, input interfaces.CountResourceInput) (int64, error) {
if r.countFunction != nil {
return r.countFunction(ctx, input)
}
return 0, nil
}
func (r *MockNodeExecutionRepo) SetCountCallback(countFunction CountNodeExecutionFunc) {
r.countFunction = countFunction
}
func NewMockNodeExecutionRepo() interfaces.NodeExecutionRepoInterface {
return &MockNodeExecutionRepo{}
}