[MM-19120] Migrate tests from "model/security_bulletin_test.go… (#12567)
Этот коммит содержится в:
коммит произвёл
Ben Schumacher
родитель
6c55f79ca7
Коммит
2ef5712a08
@@ -4,6 +4,7 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@@ -17,16 +18,12 @@ func TestSecurityBulletinToFromJson(t *testing.T) {
|
|||||||
j := b.ToJson()
|
j := b.ToJson()
|
||||||
b1 := SecurityBulletinFromJson(strings.NewReader(j))
|
b1 := SecurityBulletinFromJson(strings.NewReader(j))
|
||||||
|
|
||||||
CheckString(t, b1.AppliesToVersion, b.AppliesToVersion)
|
require.Equal(t, b, *b1)
|
||||||
CheckString(t, b1.Id, b.Id)
|
|
||||||
|
|
||||||
// Malformed JSON
|
// Malformed JSON
|
||||||
s2 := `{"wat"`
|
s2 := `{"wat"`
|
||||||
b2 := SecurityBulletinFromJson(strings.NewReader(s2))
|
b2 := SecurityBulletinFromJson(strings.NewReader(s2))
|
||||||
|
require.Nil(t, b2)
|
||||||
if b2 != nil {
|
|
||||||
t.Fatal("expected nil")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSecurityBulletinsToFromJson(t *testing.T) {
|
func TestSecurityBulletinsToFromJson(t *testing.T) {
|
||||||
@@ -45,11 +42,11 @@ func TestSecurityBulletinsToFromJson(t *testing.T) {
|
|||||||
|
|
||||||
b1 := SecurityBulletinsFromJson(strings.NewReader(j))
|
b1 := SecurityBulletinsFromJson(strings.NewReader(j))
|
||||||
|
|
||||||
CheckInt(t, len(b1), 2)
|
require.Len(t, b1, 2)
|
||||||
|
|
||||||
// Malformed JSON
|
// Malformed JSON
|
||||||
s2 := `{"wat"`
|
s2 := `{"wat"`
|
||||||
b2 := SecurityBulletinsFromJson(strings.NewReader(s2))
|
b2 := SecurityBulletinsFromJson(strings.NewReader(s2))
|
||||||
|
|
||||||
CheckInt(t, len(b2), 0)
|
require.Len(t, b2, 0)
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user