forked from sysdiglabs/kube-psp-advisor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kube-psp-advisor_test.go
47 lines (37 loc) · 908 Bytes
/
kube-psp-advisor_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
package main
import (
"sort"
"strings"
"testing"
)
var (
workloadDir = "./test-yaml"
expectedYamls = []string{
"test-yaml/base-busybox.yaml",
"test-yaml/psp-grant.yaml",
"test-yaml/srcYamls/busy-box.yaml",
"test-yaml/srcYamls/nginx.yaml",
"test-yaml/targetYamls/busy-box.yaml",
"test-yaml/targetYamls/nginx.yaml",
}
)
func TestReadYamls(t *testing.T) {
yamls, err := getWorkLoadYamls(workloadDir)
if err != nil {
t.Fatal(err)
}
sort.Strings(yamls)
if strings.Join(yamls, ";") != strings.Join(expectedYamls, ";") {
t.Fatalf("expected: %s\nactual: %s\n", expectedYamls, yamls)
}
}
func TestReadYamlFile(t *testing.T) {
testYaml := "test-yaml/base-busybox.yaml"
yamls, err := getWorkLoadYamls(testYaml)
if err != nil {
t.Fatal(err)
}
if len(yamls) != 1 && yamls[0] != "test-yaml/base-busybox.yaml" {
t.Fatalf("expected: %s\nactual: %s\n", testYaml, yamls[0])
}
}