Skip to content

Commit

Permalink
Add unit tests.
Browse files Browse the repository at this point in the history
Kubernetes-commit: 1306e5fd017c3116a41e71c3ff5866461dafe9cd
  • Loading branch information
DangerOnTheRanger authored and k8s-publishing-bot committed Aug 22, 2022
1 parent 6d0af3c commit 063c82b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pkg/apiserver/schema/cel/compilation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,27 @@ func TestCostEstimation(t *testing.T) {
setMaxElements: 10,
expectedSetCost: 6,
},
{
name: "check cost of size call",
schemaGenerator: genMapWithRule("integer", "oldSelf.size() == self.size()"),
expectedCalcCost: 5,
setMaxElements: 10,
expectedSetCost: 5,
},
{
name: "check cost of timestamp comparison",
schemaGenerator: genMapWithRule("date-time", `self["a"] == self["b"]`),
expectedCalcCost: 8,
setMaxElements: 7,
expectedSetCost: 8,
},
{
name: "check cost of duration comparison",
schemaGenerator: genMapWithRule("duration", `self["c"] == self["d"]`),
expectedCalcCost: 8,
setMaxElements: 42,
expectedSetCost: 8,
},
}
for _, testCase := range cases {
t.Run(testCase.name, func(t *testing.T) {
Expand Down

0 comments on commit 063c82b

Please sign in to comment.