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
/
project.go
47 lines (38 loc) · 1.48 KB
/
project.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
package mocks
import (
"context"
"github.com/lyft/flyteidl/gen/pb-go/flyteidl/admin"
)
type CreateProjectFunc func(ctx context.Context, request admin.ProjectRegisterRequest) (*admin.ProjectRegisterResponse, error)
type ListProjectFunc func(ctx context.Context, request admin.ProjectListRequest) (*admin.Projects, error)
type UpdateProjectFunc func(ctx context.Context, request admin.Project) (*admin.ProjectUpdateResponse, error)
type MockProjectManager struct {
listProjectFunc ListProjectFunc
createProjectFunc CreateProjectFunc
updateProjectFunc UpdateProjectFunc
}
func (m *MockProjectManager) SetCreateProject(createProjectFunc CreateProjectFunc) {
m.createProjectFunc = createProjectFunc
}
func (m *MockProjectManager) CreateProject(ctx context.Context, request admin.ProjectRegisterRequest) (*admin.ProjectRegisterResponse, error) {
if m.createProjectFunc != nil {
return m.createProjectFunc(ctx, request)
}
return nil, nil
}
func (m *MockProjectManager) UpdateProject(ctx context.Context, request admin.Project) (*admin.ProjectUpdateResponse, error) {
if m.updateProjectFunc != nil {
return m.updateProjectFunc(ctx, request)
}
return nil, nil
}
func (m *MockProjectManager) SetListCallback(listProjectFunc ListProjectFunc) {
m.listProjectFunc = listProjectFunc
}
func (m *MockProjectManager) ListProjects(
ctx context.Context, request admin.ProjectListRequest) (*admin.Projects, error) {
if m.listProjectFunc != nil {
return m.listProjectFunc(ctx, request)
}
return nil, nil
}