package decoder import ( _ "embed" // nolint let a test e m b e d "testing" ) //go:embed testdata/manifests.yaml var testManifests []byte //go:embed testdata/manifests_empty_item.yaml var testManifestsEmptyItem []byte func TestDecodeYAML(t *testing.T) { objs, err := DecodeYAML(testManifests) if err != nil { t.Error("failed to decode test fixture YAML file", err) } if len(objs) != 4 { t.Error("manifests.yaml should contain 4 API resources: ", len(objs)) } for _, o := range objs { if !isExpectedKind(o.GetKind()) { t.Error("decoded object has unexpected kind", o.GetKind()) } } } func TestDecodeYAML_EmptyItem(t *testing.T) { objs, err := DecodeYAML(testManifestsEmptyItem) if err != nil { t.Error("failed to decode test fixture YAML file", err) } if len(objs) != 4 { t.Error("manifests_empty_item.yaml should contain 4 API resources", len(objs)) } } func isExpectedKind(i string) bool { return i == "Deployment" || i == "ServiceAccount" || i == "Namespace" || i == "ClusterRoleBinding" }