mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-19120] Migrate tests from "model/security_bulletin_test.go… (#12567)
This commit is contained in:
committed by
Ben Schumacher
parent
6c55f79ca7
commit
2ef5712a08
@@ -4,6 +4,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@@ -17,16 +18,12 @@ func TestSecurityBulletinToFromJson(t *testing.T) {
|
||||
j := b.ToJson()
|
||||
b1 := SecurityBulletinFromJson(strings.NewReader(j))
|
||||
|
||||
CheckString(t, b1.AppliesToVersion, b.AppliesToVersion)
|
||||
CheckString(t, b1.Id, b.Id)
|
||||
require.Equal(t, b, *b1)
|
||||
|
||||
// Malformed JSON
|
||||
s2 := `{"wat"`
|
||||
b2 := SecurityBulletinFromJson(strings.NewReader(s2))
|
||||
|
||||
if b2 != nil {
|
||||
t.Fatal("expected nil")
|
||||
}
|
||||
require.Nil(t, b2)
|
||||
}
|
||||
|
||||
func TestSecurityBulletinsToFromJson(t *testing.T) {
|
||||
@@ -45,11 +42,11 @@ func TestSecurityBulletinsToFromJson(t *testing.T) {
|
||||
|
||||
b1 := SecurityBulletinsFromJson(strings.NewReader(j))
|
||||
|
||||
CheckInt(t, len(b1), 2)
|
||||
require.Len(t, b1, 2)
|
||||
|
||||
// Malformed JSON
|
||||
s2 := `{"wat"`
|
||||
b2 := SecurityBulletinsFromJson(strings.NewReader(s2))
|
||||
|
||||
CheckInt(t, len(b2), 0)
|
||||
require.Len(t, b2, 0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user