mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* Unit Tests for model/push_response.go * Unit tests for security_bulletin.go * Unit tests for webrtc.go * Unit tests for model/password_recovery.go * Add missing headers. * Unit tests for model/license.go * Tidy up existing tests. * Simplify JSON to/from tests. * Fix gofmt
56 lines
1.0 KiB
Go
56 lines
1.0 KiB
Go
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
package model
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestSecurityBulletinToFromJson(t *testing.T) {
|
|
b := SecurityBulletin{
|
|
Id: NewId(),
|
|
AppliesToVersion: NewId(),
|
|
}
|
|
|
|
j := b.ToJson()
|
|
b1 := SecurityBulletinFromJson(strings.NewReader(j))
|
|
|
|
CheckString(t, b1.AppliesToVersion, b.AppliesToVersion)
|
|
CheckString(t, b1.Id, b.Id)
|
|
|
|
// Malformed JSON
|
|
s2 := `{"wat"`
|
|
b2 := SecurityBulletinFromJson(strings.NewReader(s2))
|
|
|
|
if b2 != nil {
|
|
t.Fatal("expected nil")
|
|
}
|
|
}
|
|
|
|
func TestSecurityBulletinsToFromJson(t *testing.T) {
|
|
b := SecurityBulletins{
|
|
{
|
|
Id: NewId(),
|
|
AppliesToVersion: NewId(),
|
|
},
|
|
{
|
|
Id: NewId(),
|
|
AppliesToVersion: NewId(),
|
|
},
|
|
}
|
|
|
|
j := b.ToJson()
|
|
|
|
b1 := SecurityBulletinsFromJson(strings.NewReader(j))
|
|
|
|
CheckInt(t, len(b1), 2)
|
|
|
|
// Malformed JSON
|
|
s2 := `{"wat"`
|
|
b2 := SecurityBulletinsFromJson(strings.NewReader(s2))
|
|
|
|
CheckInt(t, len(b2), 0)
|
|
}
|