mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-18 09:02:13 +00:00
50 lines
886 B
Go
50 lines
886 B
Go
// Copyright 2021 The Kubernetes Authors.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package utils_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
. "sigs.k8s.io/kustomize/api/internal/utils"
|
|
)
|
|
|
|
func TestPathSplitter(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
exp []string
|
|
path string
|
|
}{
|
|
{
|
|
path: "",
|
|
exp: []string{""},
|
|
},
|
|
{
|
|
path: "s",
|
|
exp: []string{"s"},
|
|
},
|
|
{
|
|
path: "a/b/c",
|
|
exp: []string{"a", "b", "c"},
|
|
},
|
|
{
|
|
path: `a/b[]/c`,
|
|
exp: []string{"a", "b[]", "c"},
|
|
},
|
|
{
|
|
path: `a/b\/c/d\/e/f`,
|
|
exp: []string{"a", "b/c", "d/e", "f"},
|
|
},
|
|
{
|
|
// The actual reason for this.
|
|
path: `metadata/annotations/nginx.ingress.kubernetes.io\/auth-secret`,
|
|
exp: []string{
|
|
"metadata",
|
|
"annotations",
|
|
"nginx.ingress.kubernetes.io/auth-secret"},
|
|
},
|
|
} {
|
|
assert.Equal(t, tc.exp, PathSplitter(tc.path))
|
|
}
|
|
}
|