[MM-19118] Migrate tests from "model/websocket_message_test.go… (#12577)

* [MM-19118] Migrate tests from model/websocket_message_test.go to use testify

* [MM-19118] Ran go fmt on websocket_message_test.go file
This commit is contained in:
SezalAgrawal
2019-10-03 14:18:37 +05:30
committed by Michael Kochell
parent f010346945
commit eebe1fc290

View File

@@ -8,6 +8,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestWebSocketEvent(t *testing.T) {
@@ -17,21 +18,13 @@ func TestWebSocketEvent(t *testing.T) {
result := WebSocketEventFromJson(strings.NewReader(json))
badresult := WebSocketEventFromJson(strings.NewReader("junk"))
if badresult != nil {
t.Fatal("should not have parsed")
}
require.Nil(t, badresult, "should not have parsed")
if !m.IsValid() {
t.Fatal("should be valid")
}
require.True(t, m.IsValid(), "should be valid")
if m.Broadcast.TeamId != result.Broadcast.TeamId {
t.Fatal("Ids do not match")
}
require.Equal(t, m.Broadcast.TeamId, result.Broadcast.TeamId, "Ids do not match")
if m.Data["RootId"] != result.Data["RootId"] {
t.Fatal("Ids do not match")
}
require.Equal(t, m.Data["RootId"], result.Data["RootId"], "Ids do not match")
}
func TestWebSocketResponse(t *testing.T) {
@@ -44,17 +37,11 @@ func TestWebSocketResponse(t *testing.T) {
WebSocketResponseFromJson(strings.NewReader(json2))
badresult := WebSocketResponseFromJson(strings.NewReader("junk"))
if badresult != nil {
t.Fatal("should not have parsed")
}
require.Nil(t, badresult, "should not have parsed")
if !m.IsValid() {
t.Fatal("should be valid")
}
require.True(t, m.IsValid(), "should be valid")
if m.Data["RootId"] != result.Data["RootId"] {
t.Fatal("Ids do not match")
}
require.Equal(t, m.Data["RootId"], result.Data["RootId"], "Ids do not match")
}
func TestWebSocketEvent_PrecomputeJSON(t *testing.T) {