Make test file paths consistent and relative

Signed-off-by: Mikhail Nikitin <mikhail.nikitin@ispringsolutions.com>
This commit is contained in:
Mikhail Nikitin
2021-01-15 22:50:23 +03:00
parent e13f8803eb
commit f6ddea435c

View File

@@ -10,7 +10,7 @@ func TestPatchDeleteOfNotExistingAttributesShouldNotAddExtraElements(t *testing.
th := kusttest_test.MakeEnhancedHarness(t) th := kusttest_test.MakeEnhancedHarness(t)
defer th.Reset() defer th.Reset()
th.WriteF("/app/resource.yaml", ` th.WriteF("resource.yaml", `
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
@@ -27,7 +27,7 @@ spec:
name: whatever name: whatever
image: helloworld image: helloworld
`) `)
th.WriteF("/app/patch.yml", ` th.WriteF("patch.yaml", `
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
@@ -43,18 +43,17 @@ spec:
- name: NOT_EXISTING_FOR_REMOVAL - name: NOT_EXISTING_FOR_REMOVAL
$patch: delete $patch: delete
`) `)
th.WriteK("/app", ` th.WriteK(".", `
resources: resources:
- resource.yaml - resource.yaml
patches: patches:
- path: patch.yml - path: patch.yaml
target: target:
kind: Deployment kind: Deployment
`) `)
/*
// It's expected that removal of not existing elements should not introduce extra values, // It's expected that removal of not existing elements should not introduce extra values,
// as a patch can be applied to multipe resources, not all of them can have all deleted elements. // as a patch can be applied to multiple resources, not all of them can have all the elements being deleted.
expected := ` expected := `
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
@@ -70,9 +69,10 @@ patches:
image: helloworld image: helloworld
name: whatever name: whatever
` `
*/ // Allow expected variable to be unused
_ = expected
// Currently kustomize inserts $patch: delete elements into the resulting resources // Currently, kustomize inserts $patch: delete elements into the resulting resources
erroneousActual := ` erroneousActual := `
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
@@ -91,6 +91,6 @@ spec:
name: whatever name: whatever
` `
m := th.Run("/app", th.MakeDefaultOptions()) m := th.Run(".", th.MakeDefaultOptions())
th.AssertActualEqualsExpected(m, erroneousActual) th.AssertActualEqualsExpected(m, erroneousActual)
} }