diff --git a/api/krusty/component_test.go b/api/krusty/component_test.go index 5ab861fe3..bc1d1be82 100644 --- a/api/krusty/component_test.go +++ b/api/krusty/component_test.go @@ -359,18 +359,18 @@ resources: } } -func TestResourcesCannotBeAddedToComponents(t *testing.T) { +func TestKustomizationsCannotBeAddedToComponents(t *testing.T) { th := kusttest_test.MakeHarness(t) writeComponentBase(th) writeComponentPatch(th) - th.WriteF("/app/resincust/kustomization.yaml", ` + th.WriteF("/app/kustincomponents/kustomization.yaml", ` apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization components: - ../base - ../patch `) - err := th.RunWithErr("/app/resincust", th.MakeDefaultOptions()) + err := th.RunWithErr("/app/kustincomponents", th.MakeDefaultOptions()) if !strings.Contains( err.Error(), "accumulating components: accumulateDirectory: \"expected kind 'Component' for path '/app/base' but got 'Kustomization'") { @@ -378,6 +378,34 @@ components: } } +func TestFilesCannotBeAddedToComponentsList(t *testing.T) { + th := kusttest_test.MakeHarness(t) + writeComponentBase(th) + + th.WriteF("/app/filesincomponents/stub.yaml", ` +apiVersion: v1 +kind: Deployment +metadata: + name: stub +spec: + replicas: 1 +`) + + th.WriteF("/app/filesincomponents/kustomization.yaml", ` +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +components: +- stub.yaml +- ../patch +`) + err := th.RunWithErr("/app/filesincomponents", th.MakeDefaultOptions()) + if !strings.Contains( + err.Error(), + "'/app/filesincomponents/stub.yaml' must be a directory to be a root") { + t.Fatalf("unexpected error: %s", err) + } +} + func TestMissingOptionalComponentApiVersion(t *testing.T) { th := kusttest_test.MakeHarness(t) writeComponentBase(th)