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
/
task_execution_repo.go
81 lines (66 loc) · 2.68 KB
/
task_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
package mocks
import (
"context"
"github.com/flyteorg/flyteadmin/pkg/repositories/interfaces"
"github.com/flyteorg/flyteadmin/pkg/repositories/models"
)
type CreateTaskExecutionFunc func(ctx context.Context, input models.TaskExecution) error
type GetTaskExecutionFunc func(ctx context.Context, input interfaces.GetTaskExecutionInput) (models.TaskExecution, error)
type UpdateTaskExecutionFunc func(ctx context.Context, execution models.TaskExecution) error
type ListTaskExecutionFunc func(ctx context.Context, input interfaces.ListResourceInput) (interfaces.TaskExecutionCollectionOutput, error)
type CountTaskExecutionFunc func(ctx context.Context, input interfaces.CountResourceInput) (int64, error)
type MockTaskExecutionRepo struct {
createFunction CreateTaskExecutionFunc
getFunction GetTaskExecutionFunc
updateFunction UpdateTaskExecutionFunc
listFunction ListTaskExecutionFunc
countFunction CountTaskExecutionFunc
}
func (r *MockTaskExecutionRepo) Create(ctx context.Context, input models.TaskExecution) error {
if r.createFunction != nil {
return r.createFunction(ctx, input)
}
return nil
}
func (r *MockTaskExecutionRepo) SetCreateCallback(createFunction CreateTaskExecutionFunc) {
r.createFunction = createFunction
}
func (r *MockTaskExecutionRepo) Get(ctx context.Context, input interfaces.GetTaskExecutionInput) (models.TaskExecution, error) {
if r.getFunction != nil {
return r.getFunction(ctx, input)
}
return models.TaskExecution{}, nil
}
func (r *MockTaskExecutionRepo) SetGetCallback(getFunction GetTaskExecutionFunc) {
r.getFunction = getFunction
}
func (r *MockTaskExecutionRepo) Update(ctx context.Context, execution models.TaskExecution) error {
if r.updateFunction != nil {
return r.updateFunction(ctx, execution)
}
return nil
}
func (r *MockTaskExecutionRepo) SetUpdateCallback(updateFunction UpdateTaskExecutionFunc) {
r.updateFunction = updateFunction
}
func (r *MockTaskExecutionRepo) List(ctx context.Context, input interfaces.ListResourceInput) (interfaces.TaskExecutionCollectionOutput, error) {
if r.listFunction != nil {
return r.listFunction(ctx, input)
}
return interfaces.TaskExecutionCollectionOutput{}, nil
}
func (r *MockTaskExecutionRepo) SetListCallback(listFunction ListTaskExecutionFunc) {
r.listFunction = listFunction
}
func (r *MockTaskExecutionRepo) Count(ctx context.Context, input interfaces.CountResourceInput) (int64, error) {
if r.countFunction != nil {
return r.countFunction(ctx, input)
}
return 0, nil
}
func (r *MockTaskExecutionRepo) SetCountCallback(countFunction CountTaskExecutionFunc) {
r.countFunction = countFunction
}
func NewMockTaskExecutionRepo() interfaces.TaskExecutionRepoInterface {
return &MockTaskExecutionRepo{}
}