From 15905b2db29777b88091333cd25d88193f1fb725 Mon Sep 17 00:00:00 2001 From: Justin Ting Date: Fri, 18 Apr 2025 08:48:29 +1000 Subject: [PATCH] chore - add missing unknown priority --- pkg/models/priority.go | 17 ++++++++++++++--- pkg/models/priority_test.go | 4 ++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pkg/models/priority.go b/pkg/models/priority.go index 1980790..c081ef5 100644 --- a/pkg/models/priority.go +++ b/pkg/models/priority.go @@ -4,18 +4,29 @@ const ( PriorityUrgent string = "URGENT" PriorityImportant string = "IMPORTANT" PriorityInformational string = "INFORMATIONAL" + PriorityUnknown string = "UNKNOWN" ) var priorityToInt = map[string]int{ - PriorityInformational: 0, - PriorityImportant: 1, - PriorityUrgent: 2, + PriorityUnknown: 0, + PriorityInformational: 1, + PriorityImportant: 2, + PriorityUrgent: 3, } func ComparePriority(priority1, priority2 string) int { val1, ok1 := priorityToInt[priority1] val2, ok2 := priorityToInt[priority2] + // If priority1 is NONE and priority2 is not in the map, treat them as equal + if priority1 == PriorityUnknown && !ok2 { + return 0 + } + // If priority2 is NONE and priority1 is not in the map, treat them as equal + if priority2 == PriorityUnknown && !ok1 { + return 0 + } + if !ok1 && !ok2 { return 0 } else if !ok1 { diff --git a/pkg/models/priority_test.go b/pkg/models/priority_test.go index ef48c78..78281d9 100644 --- a/pkg/models/priority_test.go +++ b/pkg/models/priority_test.go @@ -20,6 +20,10 @@ func TestComparePriority(t *testing.T) { {"INFORMATIONAL", "INFORMATIONAL", 0}, {"IMPORTANT", "IMPORTANT", 0}, {"URGENT", "URGENT", 0}, + {"NONE", "INVALID", 0}, + {"NONE", "UNKNOWN", 0}, + {"UNKNOWN", "", 0}, + {"", "UNKNOWN", 0}, } for _, test := range tests {