Skip to content

Commit

Permalink
Update validation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bjee19 committed Sep 11, 2024
1 parent 9713d80 commit 54d0e29
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,19 @@ func TestValidator_Validate(t *testing.T) {
return p
}),
expConditions: []conditions.Condition{
staticConds.NewPolicyInvalid("[spec.body.timeout: Invalid value: \"invalid\": \\d{1,4}(ms|s)? " +
"(e.g. '5ms', or '10s', regex used for validation is 'must contain a number followed by 'ms' or 's''), " +
"spec.keepAlive.time: Invalid value: \"invalid\": \\d{1,4}(ms|s)? (e.g. '5ms', or '10s', regex used for " +
"validation is 'must contain a number followed by 'ms' or 's''), spec.keepAlive.timeout.server: Invalid value: " +
"\"invalid\": \\d{1,4}(ms|s)? (e.g. '5ms', or '10s', regex used for validation is 'must contain a number " +
"followed by 'ms' or 's''), spec.keepAlive.timeout.header: Invalid value: \"invalid\": \\d{1,4}(ms|s)? " +
"(e.g. '5ms', or '10s', regex used for validation is 'must contain a number followed by 'ms' or 's'')]"),
staticConds.NewPolicyInvalid(
"[spec.body.timeout: Invalid value: \"invalid\": ^[0-9]{1,4}(ms|s|m|h)? " +
"(e.g. '5ms', or '10s', or '500m', or '1000h', regex used for validation is " +
"'must contain an, at most, four digit number followed by 'ms', 's', 'm', or 'h''), " +
"spec.keepAlive.time: Invalid value: \"invalid\": ^[0-9]{1,4}(ms|s|m|h)? " +
"(e.g. '5ms', or '10s', or '500m', or '1000h', regex used for validation is " +
"'must contain an, at most, four digit number followed by 'ms', 's', 'm', or 'h''), " +
"spec.keepAlive.timeout.server: Invalid value: \"invalid\": ^[0-9]{1,4}(ms|s|m|h)? " +
"(e.g. '5ms', or '10s', or '500m', or '1000h', regex used for validation is " +
"'must contain an, at most, four digit number followed by 'ms', 's', 'm', or 'h''), " +
"spec.keepAlive.timeout.header: Invalid value: \"invalid\": ^[0-9]{1,4}(ms|s|m|h)? " +
"(e.g. '5ms', or '10s', or '500m', or '1000h', regex used for validation is " +
"'must contain an, at most, four digit number followed by 'ms', 's', 'm', or 'h'')]"),
},
},
{
Expand Down
4 changes: 3 additions & 1 deletion internal/mode/static/nginx/config/validation/generic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ func TestValidateNginxDuration(t *testing.T) {
`5ms`,
`10s`,
`123ms`,
`5m`,
`2h`,
)

testInvalidValuesForSimpleValidator(
t,
validator.ValidateNginxDuration,
`test`,
`12345`,
`5m`,
`5k`,
)
}

Expand Down

0 comments on commit 54d0e29

Please sign in to comment.