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
83 lines (68 loc) · 2.51 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
package mocks
import (
"context"
"github.com/flyteorg/flyteadmin/pkg/repositories/interfaces"
"github.com/flyteorg/flyteadmin/pkg/repositories/models"
)
type CreateExecutionFunc func(ctx context.Context, input models.Execution) error
type UpdateExecutionFunc func(ctx context.Context, execution models.Execution) error
type GetExecutionFunc func(ctx context.Context, input interfaces.Identifier) (models.Execution, error)
type ListExecutionFunc func(ctx context.Context, input interfaces.ListResourceInput) (
interfaces.ExecutionCollectionOutput, error)
type CountExecutionFunc func(ctx context.Context, input interfaces.CountResourceInput) (int64, error)
type MockExecutionRepo struct {
createFunction CreateExecutionFunc
updateFunction UpdateExecutionFunc
getFunction GetExecutionFunc
listFunction ListExecutionFunc
countFunction CountExecutionFunc
}
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, execution models.Execution) error {
if r.updateFunction != nil {
return r.updateFunction(ctx, execution)
}
return nil
}
func (r *MockExecutionRepo) SetUpdateCallback(updateFunction UpdateExecutionFunc) {
r.updateFunction = updateFunction
}
func (r *MockExecutionRepo) Get(ctx context.Context, input interfaces.Identifier) (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) 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 (r *MockExecutionRepo) Count(ctx context.Context, input interfaces.CountResourceInput) (int64, error) {
if r.countFunction != nil {
return r.countFunction(ctx, input)
}
return 0, nil
}
func (r *MockExecutionRepo) SetCountCallback(countFunction CountExecutionFunc) {
r.countFunction = countFunction
}
func NewMockExecutionRepo() interfaces.ExecutionRepoInterface {
return &MockExecutionRepo{}
}