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
/
launch_plan_repo.go
107 lines (90 loc) · 3.3 KB
/
launch_plan_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
// Mock implementation of a workflow repo to be used for tests.
package mocks
import (
"context"
"github.com/flyteorg/flyteadmin/pkg/repositories/interfaces"
"github.com/flyteorg/flyteadmin/pkg/repositories/models"
)
type CreateLaunchPlanFunc func(input models.LaunchPlan) error
type UpdateLaunchPlanFunc func(input models.LaunchPlan) error
type SetActiveLaunchPlanFunc func(toEnable models.LaunchPlan, toDisable *models.LaunchPlan) error
type GetLaunchPlanFunc func(input interfaces.Identifier) (models.LaunchPlan, error)
type ListLaunchPlanFunc func(input interfaces.ListResourceInput) (interfaces.LaunchPlanCollectionOutput, error)
type ListLaunchPlanIdentifiersFunc func(input interfaces.ListResourceInput) (
interfaces.LaunchPlanCollectionOutput, error)
type MockLaunchPlanRepo struct {
createFunction CreateLaunchPlanFunc
updateFunction UpdateLaunchPlanFunc
setActiveFunction SetActiveLaunchPlanFunc
getFunction GetLaunchPlanFunc
listFunction ListLaunchPlanFunc
listIdsFunction ListLaunchPlanIdentifiersFunc
}
func (r *MockLaunchPlanRepo) Create(ctx context.Context, input models.LaunchPlan) error {
if r.createFunction != nil {
return r.createFunction(input)
}
return nil
}
func (r *MockLaunchPlanRepo) SetCreateCallback(createFunction CreateLaunchPlanFunc) {
r.createFunction = createFunction
}
func (r *MockLaunchPlanRepo) Update(ctx context.Context, launchPlan models.LaunchPlan) error {
if r.updateFunction != nil {
return r.updateFunction(launchPlan)
}
return nil
}
func (r *MockLaunchPlanRepo) SetUpdateCallback(updateFunction UpdateLaunchPlanFunc) {
r.updateFunction = updateFunction
}
func (r *MockLaunchPlanRepo) SetActive(
ctx context.Context, toEnable models.LaunchPlan, toDisable *models.LaunchPlan) error {
if r.setActiveFunction != nil {
return r.setActiveFunction(toEnable, toDisable)
}
return nil
}
func (r *MockLaunchPlanRepo) SetSetActiveCallback(setActiveFunction SetActiveLaunchPlanFunc) {
r.setActiveFunction = setActiveFunction
}
func (r *MockLaunchPlanRepo) Get(
ctx context.Context, input interfaces.Identifier) (models.LaunchPlan, error) {
if r.getFunction != nil {
return r.getFunction(input)
}
return models.LaunchPlan{
LaunchPlanKey: models.LaunchPlanKey{
Project: input.Project,
Domain: input.Domain,
Name: input.Name,
Version: input.Version,
},
}, nil
}
func (r *MockLaunchPlanRepo) SetGetCallback(getFunction GetLaunchPlanFunc) {
r.getFunction = getFunction
}
func (r *MockLaunchPlanRepo) List(ctx context.Context, input interfaces.ListResourceInput) (
interfaces.LaunchPlanCollectionOutput, error) {
if r.listFunction != nil {
return r.listFunction(input)
}
return interfaces.LaunchPlanCollectionOutput{}, nil
}
func (r *MockLaunchPlanRepo) SetListCallback(listFunction ListLaunchPlanFunc) {
r.listFunction = listFunction
}
func (r *MockLaunchPlanRepo) ListLaunchPlanIdentifiers(ctx context.Context, input interfaces.ListResourceInput) (
interfaces.LaunchPlanCollectionOutput, error) {
if r.listIdsFunction != nil {
return r.listIdsFunction(input)
}
return interfaces.LaunchPlanCollectionOutput{}, nil
}
func (r *MockLaunchPlanRepo) SetListLaunchPlanIdentifiersCallback(fn ListLaunchPlanIdentifiersFunc) {
r.listIdsFunction = fn
}
func NewMockLaunchPlanRepo() interfaces.LaunchPlanRepoInterface {
return &MockLaunchPlanRepo{}
}