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
/
execution_repo.go
96 lines (79 loc) · 3.04 KB
/
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
package mocks
import (
"context"
"github.com/lyft/flyteadmin/pkg/repositories/interfaces"
"github.com/lyft/flyteadmin/pkg/repositories/models"
)
type CreateExecutionFunc func(ctx context.Context, input models.Execution) error
type UpdateFunc func(ctx context.Context, event models.ExecutionEvent, execution models.Execution) error
type UpdateExecutionFunc func(ctx context.Context, execution models.Execution) error
type GetExecutionFunc func(ctx context.Context, input interfaces.GetResourceInput) (models.Execution, error)
type GetExecutionByIDFunc func(ctx context.Context, id uint) (models.Execution, error)
type ListExecutionFunc func(ctx context.Context, input interfaces.ListResourceInput) (
interfaces.ExecutionCollectionOutput, error)
type MockExecutionRepo struct {
createFunction CreateExecutionFunc
updateFunction UpdateFunc
updateExecutionFunc UpdateExecutionFunc
getFunction GetExecutionFunc
getByIDFunction GetExecutionByIDFunc
listFunction ListExecutionFunc
}
func (r *MockExecutionRepo) Create(ctx context.Context, input models.Execution) error {
if r.createFunction != nil {
return r.createFunction(ctx, input)
}
return nil
}
func (r *MockExecutionRepo) SetCreateCallback(createFunction CreateExecutionFunc) {
r.createFunction = createFunction
}
func (r *MockExecutionRepo) Update(ctx context.Context, event models.ExecutionEvent, execution models.Execution) error {
if r.updateFunction != nil {
return r.updateFunction(ctx, event, execution)
}
return nil
}
func (r *MockExecutionRepo) SetUpdateCallback(updateFunction UpdateFunc) {
r.updateFunction = updateFunction
}
func (r *MockExecutionRepo) UpdateExecution(ctx context.Context, execution models.Execution) error {
if r.updateExecutionFunc != nil {
return r.updateExecutionFunc(ctx, execution)
}
return nil
}
func (r *MockExecutionRepo) SetUpdateExecutionCallback(updateExecutionFunc UpdateExecutionFunc) {
r.updateExecutionFunc = updateExecutionFunc
}
func (r *MockExecutionRepo) Get(ctx context.Context, input interfaces.GetResourceInput) (models.Execution, error) {
if r.getFunction != nil {
return r.getFunction(ctx, input)
}
return models.Execution{}, nil
}
func (r *MockExecutionRepo) SetGetCallback(getFunction GetExecutionFunc) {
r.getFunction = getFunction
}
func (r *MockExecutionRepo) GetByID(ctx context.Context, id uint) (models.Execution, error) {
if r.getByIDFunction != nil {
return r.getByIDFunction(ctx, id)
}
return models.Execution{}, nil
}
func (r *MockExecutionRepo) SetGetByIDCallback(getByIDFunction GetExecutionByIDFunc) {
r.getByIDFunction = getByIDFunction
}
func (r *MockExecutionRepo) List(ctx context.Context, input interfaces.ListResourceInput) (
interfaces.ExecutionCollectionOutput, error) {
if r.listFunction != nil {
return r.listFunction(ctx, input)
}
return interfaces.ExecutionCollectionOutput{}, nil
}
func (r *MockExecutionRepo) SetListCallback(listFunction ListExecutionFunc) {
r.listFunction = listFunction
}
func NewMockExecutionRepo() interfaces.ExecutionRepoInterface {
return &MockExecutionRepo{}
}