mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[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:
committed by
Michael Kochell
parent
f010346945
commit
eebe1fc290
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user