forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_build_store.go
58 lines (45 loc) · 1.14 KB
/
fake_build_store.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
package test
import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
buildapi "github.com/openshift/origin/pkg/build/api"
)
type FakeBuildStore struct {
Build *buildapi.Build
Err error
}
func NewFakeBuildStore(build *buildapi.Build) FakeBuildStore {
return FakeBuildStore{Build: build}
}
func (s FakeBuildStore) Add(obj interface{}) error {
return s.Err
}
func (s FakeBuildStore) Update(obj interface{}) error {
return s.Err
}
func (s FakeBuildStore) Delete(obj interface{}) error {
return s.Err
}
func (s FakeBuildStore) List() []interface{} {
return []interface{}{s.Build}
}
func (s FakeBuildStore) ListKeys() []string {
return []string{"build"}
}
func (s FakeBuildStore) ContainedIDs() util.StringSet {
return util.NewStringSet()
}
func (s FakeBuildStore) Get(obj interface{}) (item interface{}, exists bool, err error) {
return s.GetByKey("")
}
func (s FakeBuildStore) GetByKey(id string) (item interface{}, exists bool, err error) {
if s.Err != nil {
return nil, false, err
}
if s.Build == nil {
return nil, false, nil
}
return s.Build, true, nil
}
func (s FakeBuildStore) Replace(list []interface{}) error {
return nil
}