Add an error text check for project validation
@@ -15,6 +15,7 @@ func TestValidateProject(t *testing.T) {
name string
project projectapi.Project
numErrs int
+ errText string
}{
{
name: "missing id",
@@ -145,6 +146,21 @@ func TestValidateProject(t *testing.T) {
// Should fail because infra and $test doesn't satisfy the format
numErrs: 1,
},
+ {
+ name: "valid node selector",
+ project: projectapi.Project{
+ ObjectMeta: metav1.ObjectMeta{
+ Name: "foo",
+ Namespace: "",
+ Annotations: map[string]string{
+ projectapi.ProjectNodeSelector: "env,qa",
+ },
+ },
+ },
+ // Should fail because ProjectNodeSelector is invalid
+ errText: `nodeSelector: Invalid value: "env,qa": must be a valid label selector`,
+ numErrs: 1,
+ },
}
for _, tc := range testCases {
@@ -152,6 +168,11 @@ func TestValidateProject(t *testing.T) {
if len(errs) != tc.numErrs {
t.Errorf("Unexpected error list for case %q: %+v", tc.name, errs)
}
+ for _, v := range errs {
+ if tc.errText != "" && (tc.errText != string(v.Error())) {
+ t.Errorf("Unexpected error text %q for %q", string(v.Error()), tc.errText)
+ }
+ }
}
project := projectapi.Project{
