-
Notifications
You must be signed in to change notification settings - Fork 13
/
millicore_test.go
50 lines (40 loc) · 1.16 KB
/
millicore_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
package main
import (
"errors"
"path/filepath"
"reflect"
"testing"
)
func TestGetMillicoreConfigTasks(t *testing.T) {
tasks := make(chan Task, 1)
runner := &FakeRunner{}
GetMillicoreConfigTasks(tasks, runner, []string{"project1"}, func(project, resource, substr string) ([]string, error) {
return []string{"millicore-1"}, nil
})
task := <-tasks
err := task()
if err != nil {
t.Fatal(err)
}
expectedCalls := []RunCall{
{
[]string{"oc", "-n", "project1", "exec", "millicore-1", "--", "cat", "/etc/feedhenry/cluster-override.properties"},
filepath.Join("projects", "project1", "millicore", "millicore-1_cluster-override.properties"),
},
}
if !reflect.DeepEqual(runner.Calls, expectedCalls) {
t.Errorf("runner.Calls = %q, want %q", runner.Calls, expectedCalls)
}
}
func TestMillicorePodError(t *testing.T) {
tasks := make(chan Task, 1)
runner := &FakeRunner{}
want := errors.New("error retrieving pods")
GetMillicoreConfigTasks(tasks, runner, []string{"project1"}, func(project, resource, substr string) ([]string, error) {
return nil, want
})
task := <-tasks
if err := task(); err != want {
t.Fatalf("task() = %v, want %v", err, want)
}
}