[MM-19123] Migrate tests from "model/push_notification_test.go" to use testify (#12557)

* [MM-19123] Migrate tests from model/push_notification_test.go to use testify

* [MM-19123] Re-arranged the import package
This commit is contained in:
SezalAgrawal
2019-10-04 20:00:04 +05:30
committed by George Goldberg
parent aa4a7e71dd
commit e1fae73e85

View File

@@ -6,6 +6,8 @@ package model
import (
"strings"
"testing"
"github.com/stretchr/testify/require"
)
func TestPushNotification(t *testing.T) {
@@ -13,9 +15,7 @@ func TestPushNotification(t *testing.T) {
json := msg.ToJson()
result := PushNotificationFromJson(strings.NewReader(json))
if msg.Platform != result.Platform {
t.Fatal("Ids do not match")
}
require.Equal(t, msg.Platform, result.Platform, "Ids do not match")
}
func TestPushNotificationDeviceId(t *testing.T) {
@@ -23,72 +23,44 @@ func TestPushNotificationDeviceId(t *testing.T) {
msg := PushNotification{Platform: "test"}
msg.SetDeviceIdAndPlatform("android:12345")
if msg.Platform != "android" {
t.Fatal(msg.Platform)
}
if msg.DeviceId != "12345" {
t.Fatal(msg.DeviceId)
}
require.Equal(t, msg.Platform, "android", msg.Platform)
require.Equal(t, msg.DeviceId, "12345", msg.DeviceId)
msg.Platform = ""
msg.DeviceId = ""
msg.SetDeviceIdAndPlatform("android:12:345")
if msg.Platform != "android" {
t.Fatal(msg.Platform)
}
if msg.DeviceId != "12:345" {
t.Fatal(msg.DeviceId)
}
require.Equal(t, msg.Platform, "android", msg.Platform)
require.Equal(t, msg.DeviceId, "12:345", msg.DeviceId)
msg.Platform = ""
msg.DeviceId = ""
msg.SetDeviceIdAndPlatform("android::12345")
if msg.Platform != "android" {
t.Fatal(msg.Platform)
}
if msg.DeviceId != ":12345" {
t.Fatal(msg.DeviceId)
}
require.Equal(t, msg.Platform, "android", msg.Platform)
require.Equal(t, msg.DeviceId, ":12345", msg.DeviceId)
msg.Platform = ""
msg.DeviceId = ""
msg.SetDeviceIdAndPlatform(":12345")
if msg.Platform != "" {
t.Fatal(msg.Platform)
}
if msg.DeviceId != "12345" {
t.Fatal(msg.DeviceId)
}
require.Equal(t, msg.Platform, "", msg.Platform)
require.Equal(t, msg.DeviceId, "12345", msg.DeviceId)
msg.Platform = ""
msg.DeviceId = ""
msg.SetDeviceIdAndPlatform("android:")
if msg.Platform != "android" {
t.Fatal(msg.Platform)
}
if msg.DeviceId != "" {
t.Fatal(msg.DeviceId)
}
require.Equal(t, msg.Platform, "android", msg.Platform)
require.Equal(t, msg.DeviceId, "", msg.DeviceId)
msg.Platform = ""
msg.DeviceId = ""
msg.SetDeviceIdAndPlatform("")
if msg.Platform != "" {
t.Fatal(msg.Platform)
}
if msg.DeviceId != "" {
t.Fatal(msg.DeviceId)
}
require.Equal(t, msg.Platform, "", msg.Platform)
require.Equal(t, msg.DeviceId, "", msg.DeviceId)
msg.Platform = ""
msg.DeviceId = ""
msg.SetDeviceIdAndPlatform(":")
if msg.Platform != "" {
t.Fatal(msg.Platform)
}
if msg.DeviceId != "" {
t.Fatal(msg.DeviceId)
}
require.Equal(t, msg.Platform, "", msg.Platform)
require.Equal(t, msg.DeviceId, "", msg.DeviceId)
msg.Platform = ""
msg.DeviceId = ""
}