github.com/keys-pub/mattermost-server@v4.10.10+incompatible/model/websocket_request_test.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See License.txt for license information.
     3  
     4  package model
     5  
     6  import (
     7  	"strings"
     8  	"testing"
     9  )
    10  
    11  func TestWebSocketRequest(t *testing.T) {
    12  	m := WebSocketRequest{Seq: 1, Action: "test"}
    13  	json := m.ToJson()
    14  	result := WebSocketRequestFromJson(strings.NewReader(json))
    15  
    16  	if result == nil {
    17  		t.Fatal("should not be nil")
    18  	}
    19  
    20  	badresult := WebSocketRequestFromJson(strings.NewReader("junk"))
    21  
    22  	if badresult != nil {
    23  		t.Fatal("should have been nil")
    24  	}
    25  }