forked from feedhenry/fh-system-dump-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmillicore_test.go
49 lines (40 loc) · 1.18 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
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", "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{}
GetMillicoreConfigTasks(tasks, runner, []string{"project1"}, func(project, resource, substr string) ([]string, error) {
return nil, errors.New("error retrieving pods")
})
task := <-tasks
err := task()
if err.Error() != "error retrieving pods" {
t.Fatalf("Task(): Want: error retrieving pods, Got: " + err.Error())
}
}