Prevent multiple services from being evaluated at the same time
This commit is contained in:
@ -76,7 +76,7 @@ func (service *Service) EvaluateConditions() *Result {
|
||||
result.Success = false
|
||||
}
|
||||
for _, condition := range service.Conditions {
|
||||
success := condition.Evaluate(result)
|
||||
success := condition.evaluate(result)
|
||||
if !success {
|
||||
result.Success = false
|
||||
}
|
||||
@ -93,7 +93,7 @@ type ConditionResult struct {
|
||||
|
||||
type Condition string
|
||||
|
||||
func (c *Condition) Evaluate(result *Result) bool {
|
||||
func (c *Condition) evaluate(result *Result) bool {
|
||||
condition := string(*c)
|
||||
if strings.Contains(condition, "==") {
|
||||
parts := sanitizeAndResolve(strings.Split(condition, "=="), result)
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
func TestEvaluateWithIp(t *testing.T) {
|
||||
condition := Condition("[IP] == 127.0.0.1")
|
||||
result := &Result{Ip: "127.0.0.1"}
|
||||
condition.Evaluate(result)
|
||||
condition.evaluate(result)
|
||||
if !result.ConditionResults[0].Success {
|
||||
t.Errorf("Condition '%s' should have been a success", condition)
|
||||
}
|
||||
@ -16,7 +16,7 @@ func TestEvaluateWithIp(t *testing.T) {
|
||||
func TestEvaluateWithStatus(t *testing.T) {
|
||||
condition := Condition("[STATUS] == 201")
|
||||
result := &Result{HttpStatus: 201}
|
||||
condition.Evaluate(result)
|
||||
condition.evaluate(result)
|
||||
if !result.ConditionResults[0].Success {
|
||||
t.Errorf("Condition '%s' should have been a success", condition)
|
||||
}
|
||||
@ -25,7 +25,7 @@ func TestEvaluateWithStatus(t *testing.T) {
|
||||
func TestEvaluateWithFailure(t *testing.T) {
|
||||
condition := Condition("[STATUS] == 200")
|
||||
result := &Result{HttpStatus: 500}
|
||||
condition.Evaluate(result)
|
||||
condition.evaluate(result)
|
||||
if result.ConditionResults[0].Success {
|
||||
t.Errorf("Condition '%s' should have been a failure", condition)
|
||||
}
|
||||
|
Reference in New Issue
Block a user