Improve test coverage for duration parsing
This commit is contained in:
parent
573b5f89e1
commit
5699a1c236
@ -60,7 +60,27 @@ func TestCondition_evaluateWithResponseTimeUsingLessThan(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCondition_evaluateWithResponseTimeUsingLessThanDuration(t *testing.T) {
|
||||||
|
condition := Condition("[RESPONSE_TIME] < 1s")
|
||||||
|
result := &Result{Duration: time.Millisecond * 50}
|
||||||
|
condition.evaluate(result)
|
||||||
|
if !result.ConditionResults[0].Success {
|
||||||
|
t.Errorf("Condition '%s' should have been a success", condition)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCondition_evaluateWithResponseTimeUsingLessThanInvalid(t *testing.T) {
|
||||||
|
condition := Condition("[RESPONSE_TIME] < potato")
|
||||||
|
result := &Result{Duration: time.Millisecond * 50}
|
||||||
|
condition.evaluate(result)
|
||||||
|
if result.ConditionResults[0].Success {
|
||||||
|
t.Errorf("Condition '%s' should have failed because the condition has an invalid numerical value that should've automatically resolved to 0", condition)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestCondition_evaluateWithResponseTimeUsingGreaterThan(t *testing.T) {
|
func TestCondition_evaluateWithResponseTimeUsingGreaterThan(t *testing.T) {
|
||||||
|
// Not exactly sure why you'd want to have a condition that checks if the response time is too fast,
|
||||||
|
// but hey, who am I to judge?
|
||||||
condition := Condition("[RESPONSE_TIME] > 500")
|
condition := Condition("[RESPONSE_TIME] > 500")
|
||||||
result := &Result{Duration: time.Millisecond * 750}
|
result := &Result{Duration: time.Millisecond * 750}
|
||||||
condition.evaluate(result)
|
condition.evaluate(result)
|
||||||
@ -69,6 +89,15 @@ func TestCondition_evaluateWithResponseTimeUsingGreaterThan(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCondition_evaluateWithResponseTimeUsingGreaterThanDuration(t *testing.T) {
|
||||||
|
condition := Condition("[RESPONSE_TIME] > 1s")
|
||||||
|
result := &Result{Duration: time.Second * 2}
|
||||||
|
condition.evaluate(result)
|
||||||
|
if !result.ConditionResults[0].Success {
|
||||||
|
t.Errorf("Condition '%s' should have been a success", condition)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestCondition_evaluateWithResponseTimeUsingGreaterThanOrEqualTo(t *testing.T) {
|
func TestCondition_evaluateWithResponseTimeUsingGreaterThanOrEqualTo(t *testing.T) {
|
||||||
condition := Condition("[RESPONSE_TIME] >= 500")
|
condition := Condition("[RESPONSE_TIME] >= 500")
|
||||||
result := &Result{Duration: time.Millisecond * 500}
|
result := &Result{Duration: time.Millisecond * 500}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user