Skip to content

Commit 3b35a02

Browse files
committed
fix CC CEL tests
1 parent 4379939 commit 3b35a02

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

internal/controllers/clusterclass/clusterclass_controller_test.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -974,8 +974,8 @@ func TestReconciler_reconcileVariables(t *testing.T) {
974974
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
975975
Type: "string",
976976
XValidations: []clusterv1.ValidationRule{{
977-
// Note: IP will be only available if the compatibility version is 1.30
978-
Rule: "ip(self).family() == 6",
977+
// Note: format will be only available if the compatibility version is 1.31
978+
Rule: "format.date().validate(\"2021-01-01\")",
979979
}},
980980
},
981981
},
@@ -984,13 +984,16 @@ func TestReconciler_reconcileVariables(t *testing.T) {
984984
},
985985
wantErrMessage: "failed to discover variables for ClusterClass class1: " +
986986
"patch1.variables[someIP].schema.openAPIV3Schema.x-kubernetes-validations[0].rule: Invalid value: " +
987-
"apiextensions.ValidationRule{Rule:\"ip(self).family() == 6\", Message:\"\", MessageExpression:\"\", Reason:(*apiextensions.FieldValueErrorReason)(nil), FieldPath:\"\", OptionalOldSelf:(*bool)(nil)}: compilation failed: " +
988-
"ERROR: <input>:1:3: undeclared reference to 'ip' (in container '')\n" +
989-
" | ip(self).family() == 6\n" +
990-
" | ..^\n" +
991-
"ERROR: <input>:1:16: undeclared reference to 'family' (in container '')\n" +
992-
" | ip(self).family() == 6\n" +
993-
" | ...............^",
987+
"apiextensions.ValidationRule{Rule:\"format.date().validate(\\\"2021-01-01\\\")\", Message:\"\", MessageExpression:\"\", " +
988+
"Reason:(*apiextensions.FieldValueErrorReason)(nil), FieldPath:\"\", OptionalOldSelf:(*bool)(nil)}: " +
989+
"compilation failed: ERROR: <input>:1:1: undeclared reference to 'format' (in container '')\n " +
990+
"| format.date().validate(\"2021-01-01\")\n " +
991+
"| ^\nERROR: <input>:1:12: undeclared reference to 'date' (in container '')\n " +
992+
"| format.date().validate(\"2021-01-01\")\n " +
993+
"| ...........^\n" +
994+
"ERROR: <input>:1:23: undeclared reference to 'validate' (in container '')\n " +
995+
"| format.date().validate(\"2021-01-01\")\n " +
996+
"| ......................^",
994997
},
995998
}
996999
for _, tt := range tests {
@@ -1010,6 +1013,7 @@ func TestReconciler_reconcileVariables(t *testing.T) {
10101013

10111014
err := r.reconcileVariables(ctx, tt.clusterClass)
10121015
if tt.wantErrMessage != "" {
1016+
g.Expect(err).To(HaveOccurred())
10131017
g.Expect(err.Error()).To(Equal(tt.wantErrMessage))
10141018
return
10151019
}

0 commit comments

Comments
 (0)