...
1 package decoder
2
3 import (
4 _ "embed"
5 "testing"
6 )
7
8
9 var testManifests []byte
10
11
12 var testManifestsEmptyItem []byte
13
14 func TestDecodeYAML(t *testing.T) {
15 objs, err := DecodeYAML(testManifests)
16 if err != nil {
17 t.Error("failed to decode test fixture YAML file", err)
18 }
19
20 if len(objs) != 4 {
21 t.Error("manifests.yaml should contain 4 API resources: ", len(objs))
22 }
23
24 for _, o := range objs {
25 if !isExpectedKind(o.GetKind()) {
26 t.Error("decoded object has unexpected kind", o.GetKind())
27 }
28 }
29 }
30
31 func TestDecodeYAML_EmptyItem(t *testing.T) {
32 objs, err := DecodeYAML(testManifestsEmptyItem)
33 if err != nil {
34 t.Error("failed to decode test fixture YAML file", err)
35 }
36
37 if len(objs) != 4 {
38 t.Error("manifests_empty_item.yaml should contain 4 API resources", len(objs))
39 }
40 }
41
42 func isExpectedKind(i string) bool {
43 return i == "Deployment" || i == "ServiceAccount" || i == "Namespace" ||
44 i == "ClusterRoleBinding"
45 }
46
View as plain text