PLT-6112: Add some more unit tests to the model package (#6142)
* 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
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
8723f61f45
Коммит
55bbf15fc7
55
model/security_bulletin_test.go
Обычный файл
55
model/security_bulletin_test.go
Обычный файл
@@ -0,0 +1,55 @@
|
||||
// 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)
|
||||
}
|
||||
Ссылка в новой задаче
Block a user