Files
mattermost/model/push_notification_test.go
Jesús Espino a63684fcb5 Consistent license message for all the go files (#13235)
* Consistent license message for all the go files

* Fixing the last set of unconsistencies with the license headers

* Addressing PR review comments

* Fixing busy.go and busy_test.go license header
2019-11-29 12:59:40 +01:00

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 = ""
}