-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix clusterresourcequota annotations validation
- Loading branch information
1 parent
d6641e0
commit 2d4e88f
Showing
7 changed files
with
115 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package create | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestParseAnnotationSelector(t *testing.T) { | ||
tests := []struct { | ||
input string | ||
parsed map[string]string | ||
errorExpected bool | ||
}{ | ||
{ | ||
input: "", | ||
parsed: nil, | ||
}, | ||
{ | ||
input: "foo=bar", | ||
parsed: map[string]string{ | ||
"foo": "bar", | ||
}, | ||
}, | ||
{ | ||
input: "deads=deads,liggitt=liggitt", | ||
parsed: map[string]string{ | ||
"deads": "deads", | ||
"liggitt": "liggitt", | ||
}, | ||
}, | ||
{ | ||
input: "liggitt=liggitt,deadliggitt", | ||
errorExpected: true, | ||
}, | ||
{ | ||
input: `"us=deads,liggitt,ffranz"`, | ||
parsed: map[string]string{ | ||
"us": "deads,liggitt,ffranz", | ||
}, | ||
}, | ||
{ | ||
input: `"us=deads,liggitt,ffranz",deadliggitt=deadliggitt`, | ||
parsed: map[string]string{ | ||
"us": "deads,liggitt,ffranz", | ||
"deadliggitt": "deadliggitt", | ||
}, | ||
}, | ||
} | ||
for _, test := range tests { | ||
parsed, err := parseAnnotationSelector(test.input) | ||
if err != nil { | ||
if !test.errorExpected { | ||
t.Fatalf("unexpected error: %s", err) | ||
} | ||
continue | ||
} | ||
if test.errorExpected { | ||
t.Fatalf("expected error, got a parsed output: %q", parsed) | ||
} | ||
if !reflect.DeepEqual(parsed, test.parsed) { | ||
t.Error("expected parsed annotation selector ", test.parsed, ", got ", parsed) | ||
} | ||
} | ||
} |
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