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 * [MM-19123] Re-arranged the import package
67 lines
1.8 KiB
Go
67 lines
1.8 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
package model
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestPushNotification(t *testing.T) {
|
|
msg := PushNotification{Platform: "test"}
|
|
json := msg.ToJson()
|
|
result := PushNotificationFromJson(strings.NewReader(json))
|
|
|
|
require.Equal(t, msg.Platform, result.Platform, "Ids do not match")
|
|
}
|
|
|
|
func TestPushNotificationDeviceId(t *testing.T) {
|
|
|
|
msg := PushNotification{Platform: "test"}
|
|
|
|
msg.SetDeviceIdAndPlatform("android:12345")
|
|
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")
|
|
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")
|
|
require.Equal(t, msg.Platform, "android", msg.Platform)
|
|
require.Equal(t, msg.DeviceId, ":12345", msg.DeviceId)
|
|
msg.Platform = ""
|
|
msg.DeviceId = ""
|
|
|
|
msg.SetDeviceIdAndPlatform(":12345")
|
|
require.Equal(t, msg.Platform, "", msg.Platform)
|
|
require.Equal(t, msg.DeviceId, "12345", msg.DeviceId)
|
|
msg.Platform = ""
|
|
msg.DeviceId = ""
|
|
|
|
msg.SetDeviceIdAndPlatform("android:")
|
|
require.Equal(t, msg.Platform, "android", msg.Platform)
|
|
require.Equal(t, msg.DeviceId, "", msg.DeviceId)
|
|
msg.Platform = ""
|
|
msg.DeviceId = ""
|
|
|
|
msg.SetDeviceIdAndPlatform("")
|
|
require.Equal(t, msg.Platform, "", msg.Platform)
|
|
require.Equal(t, msg.DeviceId, "", msg.DeviceId)
|
|
msg.Platform = ""
|
|
msg.DeviceId = ""
|
|
|
|
msg.SetDeviceIdAndPlatform(":")
|
|
require.Equal(t, msg.Platform, "", msg.Platform)
|
|
require.Equal(t, msg.DeviceId, "", msg.DeviceId)
|
|
msg.Platform = ""
|
|
msg.DeviceId = ""
|
|
}
|