blob: 4b8b26dc138112c905ed87b8ec332acb7cc7be50 (
plain)
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
39
40
41
42
43
44
45
46
47
48
|
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package model
import (
"strings"
"testing"
)
func TestWebrtcInfoResponseToFromJson(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
o := WebrtcInfoResponse{Token: NewId(), GatewayUrl: NewId()}
json := o.ToJson()
ro := WebrtcInfoResponseFromJson(strings.NewReader(json))
CheckString(t, ro.Token, o.Token)
CheckString(t, ro.GatewayUrl, o.GatewayUrl)
invalidJson := `{"wat"`
r := WebrtcInfoResponseFromJson(strings.NewReader(invalidJson))
if r != nil {
t.Fatalf("Should have failed")
}
}
func TestGatewayResponseFromJson(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
// Valid Gateway Response
s1 := `{"janus": "something"}`
g1 := GatewayResponseFromJson(strings.NewReader(s1))
CheckString(t, g1.Status, "something")
// Malformed JSON
s2 := `{"wat"`
g2 := GatewayResponseFromJson(strings.NewReader(s2))
if g2 != nil {
t.Fatal("expected nil")
}
}
|