Skip to content

Commit b6c9652

Browse files
committed
chore(ENT-923): add unit test
1 parent 1632c08 commit b6c9652

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

pkg/models/priority.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ const (
77
)
88

99
var priorityToInt = map[string]int{
10-
PriorityUrgent: 0,
10+
PriorityInformational: 0,
1111
PriorityImportant: 1,
12-
PriorityInformational: 2,
12+
PriorityUrgent: 2,
1313
}
1414

1515
func ComparePriority(priority1, priority2 string) int {

pkg/models/priority_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package models
2+
3+
import "testing"
4+
5+
func TestComparePriority(t *testing.T) {
6+
tests := []struct {
7+
priority1 string
8+
priority2 string
9+
expected int
10+
}{
11+
{"INVALID", "URGENT", -1},
12+
{"UNKNOWN", "IMPORTANT", -1},
13+
{"INFORMATIONAL", "URGENT", -1},
14+
{"IMPORTANT", "URGENT", -1},
15+
{"URGENT", "IMPORTANT", 1},
16+
{"IMPORTANT", "INFORMATIONAL", 1},
17+
{"URGENT", "UNKNOWN", 1},
18+
{"IMPORTANT", "INVALID", 1},
19+
{"UNKNOWN", "UNKNOWN", 0},
20+
{"INFORMATIONAL", "INFORMATIONAL", 0},
21+
{"IMPORTANT", "IMPORTANT", 0},
22+
{"URGENT", "URGENT", 0},
23+
}
24+
25+
for _, test := range tests {
26+
result := ComparePriority(test.priority1, test.priority2)
27+
if result != test.expected {
28+
t.Errorf("ComparePriority(%s, %s) = %d; want %d",
29+
test.priority1, test.priority2, result, test.expected)
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)