Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle anchors for wildcard annotations
- Loading branch information
1 parent
fab777c
commit 3a4592c
Showing
7 changed files
with
87 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package wildcards | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestExpandInMetadata(t *testing.T) { | ||
//testExpand(t, map[string]string{"test/*": "*"}, map[string]string{}, | ||
// map[string]string{"test/0": "0"}) | ||
|
||
testExpand(t, map[string]string{"test/*": "*"}, map[string]string{"test/test": "test"}, | ||
map[string]interface{}{"test/test": "*"}) | ||
|
||
testExpand(t, map[string]string{"=(test/*)": "test"}, map[string]string{"test/test": "test"}, | ||
map[string]interface{}{"=(test/test)": "test"}) | ||
|
||
testExpand(t, map[string]string{"test/*": "*"}, map[string]string{"test/test1": "test1", "test/test2": "test2"}, | ||
map[string]interface{}{"test/test1": "*"}) | ||
} | ||
|
||
func testExpand(t *testing.T, patternMap, resourceMap map[string]string, expectedMap map[string]interface{}) { | ||
result := replaceWildcardsInMapKeys(patternMap, resourceMap) | ||
if !reflect.DeepEqual(expectedMap, result) { | ||
t.Errorf("expected %v but received %v", expectedMap, result) | ||
} | ||
} |