From 1c0587197500d5fbfacde809d803a724c91355f1 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Fri, 6 Sep 2019 20:34:10 -0400 Subject: [PATCH] Add tests for core package --- core/types_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 core/types_test.go diff --git a/core/types_test.go b/core/types_test.go new file mode 100644 index 00000000..25d0ddb5 --- /dev/null +++ b/core/types_test.go @@ -0,0 +1,23 @@ +package core + +import ( + "testing" +) + +func TestEvaluateWithIp(t *testing.T) { + condition := Condition("$IP == 127.0.0.1") + result := &Result{Ip: "127.0.0.1"} + condition.Evaluate(result) + if result.ConditionResult[0].Success != true { + t.Error("Condition '$IP == 127.0.0.1' should have been a success") + } +} + +func TestEvaluateWithStatus(t *testing.T) { + condition := Condition("$STATUS == 201") + result := &Result{HttpStatus: 201} + condition.Evaluate(result) + if result.ConditionResult[0].Success != true { + t.Error("Condition '$STATUS == 201' should have been a success") + } +}