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
/
Copy pathnode_execution_repo.go
85 lines (70 loc) · 3.01 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
package mocks
import (
"context"
"github.com/lyft/flyteadmin/pkg/repositories/interfaces"
"github.com/lyft/flyteadmin/pkg/repositories/models"
)
type CreateNodeExecutionFunc func(ctx context.Context, event *models.NodeExecutionEvent, input *models.NodeExecution) error
type UpdateNodeExecutionFunc func(ctx context.Context, event *models.NodeExecutionEvent, nodeExecution *models.NodeExecution) error
type GetNodeExecutionFunc func(ctx context.Context, input interfaces.GetNodeExecutionInput) (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 MockNodeExecutionRepo struct {
createFunction CreateNodeExecutionFunc
updateFunction UpdateNodeExecutionFunc
getFunction GetNodeExecutionFunc
listFunction ListNodeExecutionFunc
listEventFunction ListNodeExecutionEventFunc
}
func (r *MockNodeExecutionRepo) Create(ctx context.Context, event *models.NodeExecutionEvent, input *models.NodeExecution) error {
if r.createFunction != nil {
return r.createFunction(ctx, event, input)
}
return nil
}
func (r *MockNodeExecutionRepo) SetCreateCallback(createFunction CreateNodeExecutionFunc) {
r.createFunction = createFunction
}
func (r *MockNodeExecutionRepo) Update(ctx context.Context, event *models.NodeExecutionEvent, nodeExecution *models.NodeExecution) error {
if r.updateFunction != nil {
return r.updateFunction(ctx, event, nodeExecution)
}
return nil
}
func (r *MockNodeExecutionRepo) SetUpdateCallback(updateFunction UpdateNodeExecutionFunc) {
r.updateFunction = updateFunction
}
func (r *MockNodeExecutionRepo) Get(ctx context.Context, input interfaces.GetNodeExecutionInput) (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) 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 NewMockNodeExecutionRepo() interfaces.NodeExecutionRepoInterface {
return &MockNodeExecutionRepo{}
}