Allow configuration names in application paths
This commit is contained in:
@@ -40,6 +40,20 @@ func TestNormalizeDestinationUsesLiteralMappingKeys(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeDestinationAllowsConfigApplicationPaths(t *testing.T) {
|
||||
for _, path := range []Path{Keys("config"), Keys("configkit"), Keys("outer", "config"), Keys("outer", "configkit"), Keys("config", "relative")} {
|
||||
normalized, err := normalizeDestination(path)
|
||||
if err != nil || normalized.String() != path.String() {
|
||||
t.Errorf("normalizeDestination(%q) = %q, %v", path.String(), normalized.String(), err)
|
||||
}
|
||||
}
|
||||
parent := Keys("outer")
|
||||
relative, err := normalizeDestination(Keys("config", "child"))
|
||||
if err != nil || appendDestination(parent, relative).String() != "/outer/config/child" {
|
||||
t.Fatalf("relative destination = %q, %v", relative.String(), err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMappingPlacementModeMatchesZeroValue(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -95,13 +109,11 @@ func TestNormalizeDestinationRejectsIndicesAndReservedKeys(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for name, path := range map[string]Path{
|
||||
"explicit index": Keys("items").Index(0),
|
||||
"negative index": Keys("items").Index(-1),
|
||||
"invalid path": Path{invalid: true},
|
||||
"configkit": Keys("configkit"),
|
||||
"extends": Keys("extends"),
|
||||
"nested configkit": Keys("outer", "configkit"),
|
||||
"nested extends": Keys("outer", "extends"),
|
||||
"explicit index": Keys("items").Index(0),
|
||||
"negative index": Keys("items").Index(-1),
|
||||
"invalid path": Path{invalid: true},
|
||||
"extends": Keys("extends"),
|
||||
"nested extends": Keys("outer", "extends"),
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -111,7 +123,7 @@ func TestNormalizeDestinationRejectsIndicesAndReservedKeys(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
for _, key := range []string{"myextends", "configkit2", "", ".", "..", "../x", "a.b", "a/b", "~"} {
|
||||
for _, key := range []string{"config", "configkit", "myextends", "configkit2", "", ".", "..", "../x", "a.b", "a/b", "~"} {
|
||||
t.Run("ordinary key "+key, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if _, err := normalizeDestination(Keys(key)); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user