Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/models/priority.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const (
)

var priorityToInt = map[string]int{
PriorityUrgent: 0,
PriorityInformational: 0,
PriorityImportant: 1,
PriorityInformational: 2,
PriorityUrgent: 2,
}

func ComparePriority(priority1, priority2 string) int {
Expand Down
32 changes: 32 additions & 0 deletions pkg/models/priority_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package models

import "testing"

func TestComparePriority(t *testing.T) {
tests := []struct {
priority1 string
priority2 string
expected int
}{
{"INVALID", "URGENT", -1},
{"UNKNOWN", "IMPORTANT", -1},
{"INFORMATIONAL", "URGENT", -1},
{"IMPORTANT", "URGENT", -1},
{"URGENT", "IMPORTANT", 1},
{"IMPORTANT", "INFORMATIONAL", 1},
{"URGENT", "UNKNOWN", 1},
{"IMPORTANT", "INVALID", 1},
{"UNKNOWN", "UNKNOWN", 0},
{"INFORMATIONAL", "INFORMATIONAL", 0},
{"IMPORTANT", "IMPORTANT", 0},
{"URGENT", "URGENT", 0},
}

for _, test := range tests {
result := ComparePriority(test.priority1, test.priority2)
if result != test.expected {
t.Errorf("ComparePriority(%s, %s) = %d; want %d",
test.priority1, test.priority2, result, test.expected)
}
}
}
Loading