-
Notifications
You must be signed in to change notification settings - Fork 29
/
tempdir_test.go
68 lines (55 loc) · 1.08 KB
/
tempdir_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
57
58
59
60
61
62
63
64
65
66
67
68
package chartify
import (
"testing"
"github.com/google/go-cmp/cmp"
)
func TestGenerateID(t *testing.T) {
type testcase struct {
release string
chart string
opts ChartifyOpts
want string
}
ids := map[string]int{}
run := func(tc testcase) {
t.Helper()
got, err := GenerateID(tc.release, tc.chart, &tc.opts)
if err != nil {
t.Fatalf("uenxpected error: %v", err)
}
if d := cmp.Diff(tc.want, got); d != "" {
t.Fatalf("unexpected result: want (-), got (+):\n%s", d)
}
ids[got]++
}
run(testcase{
release: "foo",
chart: "incubator/raw",
opts: ChartifyOpts{},
want: "foo-6f46b78b5b",
})
run(testcase{
release: "foo",
chart: "stable/envoy",
opts: ChartifyOpts{},
want: "foo-6d8599cd4f",
})
run(testcase{
release: "bar",
chart: "incubator/raw",
opts: ChartifyOpts{},
want: "bar-fdcc5d457",
})
run(testcase{
release: "foo",
opts: ChartifyOpts{
Namespace: "myns",
},
want: "myns-foo-7fbbf674bf",
})
for id, n := range ids {
if n > 1 {
t.Fatalf("too many occurrences of %s: %d", id, n)
}
}
}