mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[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:
committed by
George Goldberg
parent
aa4a7e71dd
commit
e1fae73e85
@@ -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 = ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user