Skip to content

Commit 0429c30

Browse files
committed
Update validation tests
1 parent ea8ad1a commit 0429c30

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

internal/mode/static/nginx/config/policies/clientsettings/validator_test.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,19 @@ func TestValidator_Validate(t *testing.T) {
103103
return p
104104
}),
105105
expConditions: []conditions.Condition{
106-
staticConds.NewPolicyInvalid("[spec.body.timeout: Invalid value: \"invalid\": \\d{1,4}(ms|s)? " +
107-
"(e.g. '5ms', or '10s', regex used for validation is 'must contain a number followed by 'ms' or 's''), " +
108-
"spec.keepAlive.time: Invalid value: \"invalid\": \\d{1,4}(ms|s)? (e.g. '5ms', or '10s', regex used for " +
109-
"validation is 'must contain a number followed by 'ms' or 's''), spec.keepAlive.timeout.server: Invalid value: " +
110-
"\"invalid\": \\d{1,4}(ms|s)? (e.g. '5ms', or '10s', regex used for validation is 'must contain a number " +
111-
"followed by 'ms' or 's''), spec.keepAlive.timeout.header: Invalid value: \"invalid\": \\d{1,4}(ms|s)? " +
112-
"(e.g. '5ms', or '10s', regex used for validation is 'must contain a number followed by 'ms' or 's'')]"),
106+
staticConds.NewPolicyInvalid(
107+
"[spec.body.timeout: Invalid value: \"invalid\": ^[0-9]{1,4}(ms|s|m|h)? " +
108+
"(e.g. '5ms', or '10s', or '500m', or '1000h', regex used for validation is " +
109+
"'must contain an, at most, four digit number followed by 'ms', 's', 'm', or 'h''), " +
110+
"spec.keepAlive.time: Invalid value: \"invalid\": ^[0-9]{1,4}(ms|s|m|h)? " +
111+
"(e.g. '5ms', or '10s', or '500m', or '1000h', regex used for validation is " +
112+
"'must contain an, at most, four digit number followed by 'ms', 's', 'm', or 'h''), " +
113+
"spec.keepAlive.timeout.server: Invalid value: \"invalid\": ^[0-9]{1,4}(ms|s|m|h)? " +
114+
"(e.g. '5ms', or '10s', or '500m', or '1000h', regex used for validation is " +
115+
"'must contain an, at most, four digit number followed by 'ms', 's', 'm', or 'h''), " +
116+
"spec.keepAlive.timeout.header: Invalid value: \"invalid\": ^[0-9]{1,4}(ms|s|m|h)? " +
117+
"(e.g. '5ms', or '10s', or '500m', or '1000h', regex used for validation is " +
118+
"'must contain an, at most, four digit number followed by 'ms', 's', 'm', or 'h'')]"),
113119
},
114120
},
115121
{

internal/mode/static/nginx/config/validation/generic_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,16 @@ func TestValidateNginxDuration(t *testing.T) {
5656
`5ms`,
5757
`10s`,
5858
`123ms`,
59+
`5m`,
60+
`2h`,
5961
)
6062

6163
testInvalidValuesForSimpleValidator(
6264
t,
6365
validator.ValidateNginxDuration,
6466
`test`,
6567
`12345`,
66-
`5m`,
68+
`5k`,
6769
)
6870
}
6971

0 commit comments

Comments
 (0)