-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathannotate_helmfile_releases_test.go
50 lines (45 loc) · 1.12 KB
/
annotate_helmfile_releases_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 (
"reflect"
"testing"
)
func TestAnnotateHelmfileReleases(t *testing.T) {
tt := []struct {
description string
releases string
expect []namespacedSecret
}{
{"multiple releases", `NAME: foo
LAST DEPLOYED: Fri Sep 30 19:44:07 2022
NAMESPACE: ns
STATUS: deployed
REVISION: 1
TEST SUITE: None
NAME: bar
LAST DEPLOYED: Fri Sep 30 19:44:07 2022
NAMESPACE: ns
STATUS: deployed
REVISION: 100
TEST SUITE: None
`, []namespacedSecret{
{namespace: "ns", secretName: "sh.helm.release.v1.foo.v1"},
{namespace: "ns", secretName: "sh.helm.release.v1.bar.v100"},
}},
{"single release", `NAME: bar
LAST DEPLOYED: Fri Sep 30 19:44:07 2022
NAMESPACE: foo
STATUS: failed
REVISION: 5
TEST SUITE: None
`, []namespacedSecret{{namespace: "foo", secretName: "sh.helm.release.v1.bar.v5"}}},
{"no release", ``, []namespacedSecret(nil)},
}
for _, tc := range tt {
t.Run(tc.description, func(t *testing.T) {
output := retrieveSecrets(tc.releases)
if !reflect.DeepEqual(tc.expect, output) {
t.Errorf("got %#v but expected %#v", output, tc.expect)
}
})
}
}