Skip to content

Commit

Permalink
fixup! test: Add test case for quantity value
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmidyson committed Sep 26, 2024
1 parent 348a4b6 commit 36861cf
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions internal/topology/variables/cluster_variable_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2339,6 +2339,31 @@ func Test_ValidateClusterVariable(t *testing.T) {
),
invalidType(`oneOfExampleField in body must be of type integer: "object"`, "spec.topology.variables[test].value.oneOfExampleField"),
},
}, {
name: "Valid object for int-or-string (resource.Quantity)",
clusterClassVariable: &clusterv1.ClusterClassVariable{
Name: "quantityArray",
Required: true,
Schema: clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Type: "array",
Items: &clusterv1.JSONSchemaProps{
AnyOf: []clusterv1.JSONSchemaProps{{
Type: "integer",
}, {
Type: "string",
Pattern: `^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$`,
}},
},
},
},
},
clusterVariable: &clusterv1.ClusterVariable{
Name: "quantity",
Value: apiextensionsv1.JSON{
Raw: []byte(`["500000G", "200M", "0.2G"]`),
},
},
},
}
for _, tt := range tests {
Expand Down

0 comments on commit 36861cf

Please sign in to comment.