SEBA-688 add model tests

Change-Id: Ia50dc7aae5529a6e005645bc7461944caa82a329
diff --git a/testutils/testutils.go b/testutils/testutils.go
index da290b8..64fdbcb 100644
--- a/testutils/testutils.go
+++ b/testutils/testutils.go
@@ -16,10 +16,14 @@
 package testutils
 
 import (
+	"encoding/json"
+	"errors"
 	"fmt"
 	"os"
 	"os/exec"
+	"reflect"
 	"strings"
+	"testing"
 )
 
 const (
@@ -91,3 +95,39 @@
 
 	return strings.Contains(string(out), "Listening for requests"), nil
 }
+
+// Assert that two JSON-encoded strings are equal
+func AssertJSONEqual(t *testing.T, actual string, expected string) error {
+	var expected_json interface{}
+	err := json.Unmarshal([]byte(expected), &expected_json)
+	if err != nil {
+		t.Errorf("Failed to unmarshal expected json %s", expected)
+		return err
+	}
+
+	var actual_json interface{}
+	err = json.Unmarshal([]byte(actual), &actual_json)
+	if err != nil {
+		t.Errorf("Failed to unmarshal actual json %s", actual_json)
+		return err
+	}
+
+	if !reflect.DeepEqual(expected_json, actual_json) {
+		t.Errorf("Actual json does not match expected json\nACTUAL:\n%s\nEXPECTED:\n%s", actual, expected)
+	}
+
+	return nil
+}
+
+// Assert that the error string is what we expect
+func AssertErrorEqual(t *testing.T, err error, expected string) error {
+	if err == nil {
+		t.Error("Expected an error, but received nil")
+		return errors.New("AssertErrorEqual")
+	}
+	if err.Error() != expected {
+		t.Errorf("Expected error `%s` but received actual error `%s`", expected, err.Error())
+		return errors.New("AssertErrorEqual")
+	}
+	return nil
+}