From e1fae73e8533ac9a2eb146cb0e07909bc7f78f74 Mon Sep 17 00:00:00 2001 From: SezalAgrawal Date: Fri, 4 Oct 2019 20:00:04 +0530 Subject: [PATCH] [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 --- model/push_notification_test.go | 62 +++++++++------------------------ 1 file changed, 17 insertions(+), 45 deletions(-) diff --git a/model/push_notification_test.go b/model/push_notification_test.go index a6e158105b..e2d7de1a5e 100644 --- a/model/push_notification_test.go +++ b/model/push_notification_test.go @@ -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 = "" }