File tree Expand file tree Collapse file tree 2 files changed +50
-2
lines changed Expand file tree Collapse file tree 2 files changed +50
-2
lines changed Original file line number Diff line number Diff line change @@ -4,12 +4,24 @@ const (
44 PriorityUrgent string = "URGENT"
55 PriorityImportant string = "IMPORTANT"
66 PriorityInformational string = "INFORMATIONAL"
7+
8+ // To be deprecated
9+ PriorityNegligible string = "NEGIGIBLE"
10+ PriorityLow string = "LOW"
11+ PriorityMedium string = "MEDIUM"
12+ // important is repeated
13+ // urgent is repeated
714)
815
916var priorityToInt = map [string ]int {
1017 PriorityInformational : 0 ,
11- PriorityImportant : 1 ,
12- PriorityUrgent : 2 ,
18+ PriorityImportant : 3 ,
19+ PriorityUrgent : 4 ,
20+
21+ // To be deprecated
22+ PriorityNegligible : 0 ,
23+ PriorityLow : 1 ,
24+ PriorityMedium : 2 ,
1325}
1426
1527func ComparePriority (priority1 , priority2 string ) int {
@@ -32,3 +44,16 @@ func ComparePriority(priority1, priority2 string) int {
3244 return 0
3345 }
3446}
47+
48+ func SeverityToPriority (severity string ) string {
49+ switch severity {
50+ case "CRITICAL" :
51+ return PriorityUrgent
52+ case "HIGH" , "MEDIUM" :
53+ return PriorityImportant
54+ case "LOW" :
55+ return PriorityInformational
56+ default :
57+ return PriorityInformational
58+ }
59+ }
Original file line number Diff line number Diff line change @@ -30,3 +30,26 @@ func TestComparePriority(t *testing.T) {
3030 }
3131 }
3232}
33+
34+ func TestSeverityToPriority (t * testing.T ) {
35+ tests := []struct {
36+ name string
37+ severity string
38+ want string
39+ }{
40+ {"Critical to Urgent" , SeverityCritical , PriorityUrgent },
41+ {"High to Important" , SeverityHigh , PriorityImportant },
42+ {"Medium to Important" , SeverityMedium , PriorityImportant },
43+ {"Low to Informational" , SeverityLow , PriorityInformational },
44+ {"Unknown to Informational" , SeverityUnknown , PriorityInformational },
45+ {"Empty to Informational" , "" , PriorityInformational },
46+ }
47+
48+ for _ , tt := range tests {
49+ t .Run (tt .name , func (t * testing.T ) {
50+ if got := SeverityToPriority (tt .severity ); got != tt .want {
51+ t .Errorf ("SeverityToPriority() = %v, want %v" , got , tt .want )
52+ }
53+ })
54+ }
55+ }
You can’t perform that action at this time.
0 commit comments