-
Notifications
You must be signed in to change notification settings - Fork 13
/
definitions_test.go
56 lines (54 loc) · 1.29 KB
/
definitions_test.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
package main
import (
"path/filepath"
"reflect"
"testing"
)
func TestResourceDefinition(t *testing.T) {
tests := []struct {
project string
resource string
calls []RunCall
}{
{
project: "test-project",
resource: "deploymentconfigs",
calls: []RunCall{
{
[]string{"oc", "-n", "test-project", "get", "deploymentconfigs", "-o=json"},
filepath.Join("projects", "test-project", "definitions", "deploymentconfigs.json"),
},
},
},
{
project: "test-project",
resource: "svc/mongodb-1",
calls: []RunCall{
{
[]string{"oc", "-n", "test-project", "get", "svc/mongodb-1", "-o=json"},
filepath.Join("projects", "test-project", "definitions", "svc_mongodb-1.json"),
},
},
},
{
project: "",
resource: "persistentvolumes",
calls: []RunCall{
{
[]string{"oc", "get", "persistentvolumes", "-o=json"},
filepath.Join("definitions", "persistentvolumes.json"),
},
},
},
}
for i, tt := range tests {
runner := &FakeRunner{}
task := ResourceDefinition(runner, tt.project, tt.resource)
if err := task(); err != nil {
t.Errorf("test %d: task() = %v, want %v", i, err, nil)
}
if !reflect.DeepEqual(runner.Calls, tt.calls) {
t.Errorf("test %d: runner.Calls = %q, want %q", i, runner.Calls, tt.calls)
}
}
}