forked from smarty/assertions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serializer_test.go
38 lines (31 loc) · 1.02 KB
/
serializer_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package assertions
import (
"encoding/json"
"fmt"
"testing"
"github.com/smartystreets/goconvey/convey/reporting"
)
func TestSerializerCreatesSerializedVersionOfAssertionResult(t *testing.T) {
thing1 := Thing1{"Hi"}
thing2 := Thing2{"Bye"}
message := "Super-hip failure message."
serializer := newSerializer()
actualResult := serializer.serialize(thing1, thing2, message)
expectedResult, _ := json.Marshal(reporting.FailureView{
Message: message,
Expected: fmt.Sprintf("%+v", thing1),
Actual: fmt.Sprintf("%+v", thing2),
})
if actualResult != string(expectedResult) {
t.Errorf("\nExpected: %s\nActual: %s", string(expectedResult), actualResult)
}
actualResult = serializer.serializeDetailed(thing1, thing2, message)
expectedResult, _ = json.Marshal(reporting.FailureView{
Message: message,
Expected: fmt.Sprintf("%#v", thing1),
Actual: fmt.Sprintf("%#v", thing2),
})
if actualResult != string(expectedResult) {
t.Errorf("\nExpected: %s\nActual: %s", string(expectedResult), actualResult)
}
}