mirror of
https://github.com/TwiN/gatus.git
synced 2024-11-25 01:13:40 +01:00
test: Improve condition validation test coverage
This commit is contained in:
parent
f6a621da28
commit
fdd51869a3
@ -21,16 +21,27 @@ func TestCondition_Validate(t *testing.T) {
|
|||||||
{condition: "[STATUS] > 200", expectedErr: nil},
|
{condition: "[STATUS] > 200", expectedErr: nil},
|
||||||
{condition: "[STATUS] == any(200, 201, 202, 203)", expectedErr: nil},
|
{condition: "[STATUS] == any(200, 201, 202, 203)", expectedErr: nil},
|
||||||
{condition: "[STATUS] == [BODY].status", expectedErr: nil},
|
{condition: "[STATUS] == [BODY].status", expectedErr: nil},
|
||||||
{condition: "[BODY].test == wat", expectedErr: nil},
|
{condition: "[CONNECTED] == true", expectedErr: nil},
|
||||||
|
{condition: "[RESPONSE_TIME] < 500", expectedErr: nil},
|
||||||
|
{condition: "[IP] == 127.0.0.1", expectedErr: nil},
|
||||||
|
{condition: "[BODY] == 1", expectedErr: nil},
|
||||||
{condition: "[BODY].test == wat", expectedErr: nil},
|
{condition: "[BODY].test == wat", expectedErr: nil},
|
||||||
{condition: "[BODY].test.wat == wat", expectedErr: nil},
|
{condition: "[BODY].test.wat == wat", expectedErr: nil},
|
||||||
|
{condition: "[BODY].age == [BODY].id", expectedErr: nil},
|
||||||
{condition: "[BODY].users[0].id == 1", expectedErr: nil},
|
{condition: "[BODY].users[0].id == 1", expectedErr: nil},
|
||||||
{condition: "len([BODY].users) == 100", expectedErr: nil},
|
{condition: "len([BODY].users) == 100", expectedErr: nil},
|
||||||
{condition: "has([BODY].users[0].name) == 100", expectedErr: nil},
|
{condition: "len([BODY].data) < 5", expectedErr: nil},
|
||||||
|
{condition: "has([BODY].errors) == false", expectedErr: nil},
|
||||||
|
{condition: "has([BODY].users[0].name) == true", expectedErr: nil},
|
||||||
|
{condition: "[BODY].name == pat(john*)", expectedErr: nil},
|
||||||
|
{condition: "[CERTIFICATE_EXPIRATION] > 48h", expectedErr: nil},
|
||||||
|
{condition: "[DOMAIN_EXPIRATION] > 720h", expectedErr: nil},
|
||||||
{condition: "raw == raw", expectedErr: nil},
|
{condition: "raw == raw", expectedErr: nil},
|
||||||
{condition: "[STATUS] ? 201", expectedErr: errors.New("invalid condition: [STATUS] ? 201")},
|
{condition: "[STATUS] ? 201", expectedErr: errors.New("invalid condition: [STATUS] ? 201")},
|
||||||
{condition: "[STATUS]==201", expectedErr: errors.New("invalid condition: [STATUS]==201")},
|
{condition: "[STATUS]==201", expectedErr: errors.New("invalid condition: [STATUS]==201")},
|
||||||
{condition: "[STATUS] = = 201", expectedErr: errors.New("invalid condition: [STATUS] = = 201")},
|
{condition: "[STATUS] = = 201", expectedErr: errors.New("invalid condition: [STATUS] = = 201")},
|
||||||
|
{condition: "[STATUS] ==", expectedErr: errors.New("invalid condition: [STATUS] ==")},
|
||||||
|
{condition: "[STATUS]", expectedErr: errors.New("invalid condition: [STATUS]")},
|
||||||
// FIXME: Should return an error, but doesn't because jsonpath isn't evaluated due to body being empty in Condition.Validate()
|
// FIXME: Should return an error, but doesn't because jsonpath isn't evaluated due to body being empty in Condition.Validate()
|
||||||
//{condition: "len([BODY].users == 100", expectedErr: nil},
|
//{condition: "len([BODY].users == 100", expectedErr: nil},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user