Skip to content

Commit 18f3a65

Browse files
authored
Fix Unmarshal typo, add tests to verify (#435)
1 parent 27ac52f commit 18f3a65

File tree

2 files changed

+96
-1
lines changed

2 files changed

+96
-1
lines changed

messaging/messaging.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func (a *AndroidNotification) UnmarshalJSON(b []byte) error {
263263
priorities := map[string]AndroidNotificationPriority{
264264
"PRIORITY_MIN": PriorityMin,
265265
"PRIORITY_LOW": PriorityLow,
266-
"PRIORITY_DEFUALT": PriorityDefault,
266+
"PRIORITY_DEFAULT": PriorityDefault,
267267
"PRIORITY_HIGH": PriorityHigh,
268268
"PRIORITY_MAX": PriorityMax,
269269
}

messaging/messaging_test.go

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,101 @@ var validMessages = []struct {
559559
"topic": "test-topic",
560560
},
561561
},
562+
{
563+
name: "AndroidNotificationPriorityMin",
564+
req: &Message{
565+
Android: &AndroidConfig{
566+
Notification: &AndroidNotification{
567+
Priority: PriorityMin,
568+
},
569+
},
570+
Topic: "test-topic",
571+
},
572+
want: map[string]interface{}{
573+
"android": map[string]interface{}{
574+
"notification": map[string]interface{}{
575+
"notification_priority": "PRIORITY_MIN",
576+
},
577+
},
578+
"topic": "test-topic",
579+
},
580+
},
581+
{
582+
name: "AndroidNotificationPriorityLow",
583+
req: &Message{
584+
Android: &AndroidConfig{
585+
Notification: &AndroidNotification{
586+
Priority: PriorityLow,
587+
},
588+
},
589+
Topic: "test-topic",
590+
},
591+
want: map[string]interface{}{
592+
"android": map[string]interface{}{
593+
"notification": map[string]interface{}{
594+
"notification_priority": "PRIORITY_LOW",
595+
},
596+
},
597+
"topic": "test-topic",
598+
},
599+
},
600+
{
601+
name: "AndroidNotificationPriorityDefault",
602+
req: &Message{
603+
Android: &AndroidConfig{
604+
Notification: &AndroidNotification{
605+
Priority: PriorityDefault,
606+
},
607+
},
608+
Topic: "test-topic",
609+
},
610+
want: map[string]interface{}{
611+
"android": map[string]interface{}{
612+
"notification": map[string]interface{}{
613+
"notification_priority": "PRIORITY_DEFAULT",
614+
},
615+
},
616+
"topic": "test-topic",
617+
},
618+
},
619+
{
620+
name: "AndroidNotificationPriorityHigh",
621+
req: &Message{
622+
Android: &AndroidConfig{
623+
Notification: &AndroidNotification{
624+
Priority: PriorityHigh,
625+
},
626+
},
627+
Topic: "test-topic",
628+
},
629+
want: map[string]interface{}{
630+
"android": map[string]interface{}{
631+
"notification": map[string]interface{}{
632+
"notification_priority": "PRIORITY_HIGH",
633+
},
634+
},
635+
"topic": "test-topic",
636+
},
637+
},
638+
{
639+
name: "AndroidNotificationPriorityMax",
640+
req: &Message{
641+
Android: &AndroidConfig{
642+
Notification: &AndroidNotification{
643+
Priority: PriorityMax,
644+
},
645+
},
646+
Topic: "test-topic",
647+
},
648+
want: map[string]interface{}{
649+
"android": map[string]interface{}{
650+
"notification": map[string]interface{}{
651+
"notification_priority": "PRIORITY_MAX",
652+
},
653+
},
654+
"topic": "test-topic",
655+
},
656+
},
562657
}
563658

564659
var invalidMessages = []struct {

0 commit comments

Comments
 (0)