Allow directory substrings in cycle check.

This commit is contained in:
Jeffrey Regan
2018-12-13 15:20:15 -08:00
parent bd83773a1e
commit 352ec69556
3 changed files with 41 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ package target
import (
"encoding/base64"
"path/filepath"
"reflect"
"strings"
"testing"
@@ -298,3 +299,40 @@ func TestDisableNameSuffixHash(t *testing.T) {
t.Errorf("unexpected secret resource name: %s", secret.GetName())
}
}
func write(t *testing.T, ldr loadertest.FakeLoader, dir string, content string) {
err := ldr.AddFile(
filepath.Join(dir, constants.KustomizationFileName),
[]byte(`
apiVersion: v1
kind: Kustomization
`+content))
if err != nil {
t.Fatalf("Failed to setup fake loader.")
}
}
func TestIssue596AllowDirectoriesThatAreSubstringsOfEachOther(t *testing.T) {
ldr := loadertest.NewFakeLoader(
"/app/overlays/aws-sandbox2.us-east-1")
write(t, ldr, "/app/base", "")
write(t, ldr, "/app/overlays/aws", `
bases:
- ../../base
`)
write(t, ldr, "/app/overlays/aws-nonprod", `
bases:
- ../aws
`)
write(t, ldr, "/app/overlays/aws-sandbox2.us-east-1", `
bases:
- ../aws-nonprod
`)
m, err := makeKustTarget(t, ldr).MakeCustomizedResMap()
if err != nil {
t.Fatalf("Err: %v", err)
}
if m == nil {
t.Fatalf("Empty map.")
}
}