Closed parnic closed 3 years ago
Attempt to unmarshal/deserialize a message with the PRIORITY_DEFAULT priority.
From the SDK:
if temp.Priority != "" { priorities := map[string]AndroidNotificationPriority{ "PRIORITY_MIN": PriorityMin, "PRIORITY_LOW": PriorityLow, "PRIORITY_DEFUALT": PriorityDefault, "PRIORITY_HIGH": PriorityHigh, "PRIORITY_MAX": PriorityMax, } if prio, ok := priorities[temp.Priority]; ok { a.Priority = prio } else { return fmt.Errorf("unknown priority value: %q", temp.Priority) } }
To trigger:
var validMessages = []struct { name string req *Message want map[string]interface{} }{ { name: "AndroidNotificationPriorityDefault", req: &Message{ Android: &AndroidConfig{ Notification: &AndroidNotification{ Priority: PriorityDefault, }, }, Topic: "test-topic", }, want: map[string]interface{}{ "android": map[string]interface{}{ "notification": map[string]interface{}{ "notification_priority": "PRIORITY_DEFAULT", }, }, "topic": "test-topic", }, }, } func TestJSONUnmarshal(t *testing.T) { for _, tc := range validMessages { b, err := json.Marshal(tc.req) if err != nil { t.Errorf("Marshal(%s) = %v; want = nil", tc.name, err) } var target Message if err := json.Unmarshal(b, &target); err != nil { t.Errorf("Unmarshal(%s) = %v; want = nil", tc.name, err) } if !reflect.DeepEqual(tc.req, &target) { t.Errorf("Unmarshal(%s) result = %#v; want = %#v", tc.name, tc.req, target) } } }
Thanks for the fix.
Steps to reproduce:
Attempt to unmarshal/deserialize a message with the PRIORITY_DEFAULT priority.
Relevant Code:
From the SDK:
To trigger: