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 @@ -5,13 +5,25 @@ const (
55 PriorityImportant string = "IMPORTANT"
66 PriorityInformational string = "INFORMATIONAL"
77 PriorityUnknown string = "UNKNOWN"
8+
9+ // To be deprecated
10+ PriorityNegligible string = "NEGIGIBLE"
11+ PriorityLow string = "LOW"
12+ PriorityMedium string = "MEDIUM"
13+ // important is repeated
14+ // urgent is repeated
815)
916
1017var priorityToInt = map [string ]int {
1118 PriorityUnknown : 0 ,
1219 PriorityInformational : 1 ,
13- PriorityImportant : 2 ,
14- PriorityUrgent : 3 ,
20+ PriorityImportant : 4 ,
21+ PriorityUrgent : 5 ,
22+
23+ // To be deprecated
24+ PriorityNegligible : 1 ,
25+ PriorityLow : 2 ,
26+ PriorityMedium : 3 ,
1527}
1628
1729func ComparePriority (priority1 , priority2 string ) int {
@@ -43,3 +55,16 @@ func ComparePriority(priority1, priority2 string) int {
4355 return 0
4456 }
4557}
58+
59+ func SeverityToPriority (severity string ) string {
60+ switch severity {
61+ case "CRITICAL" :
62+ return PriorityUrgent
63+ case "HIGH" , "MEDIUM" :
64+ return PriorityImportant
65+ case "LOW" :
66+ return PriorityInformational
67+ default :
68+ return PriorityInformational
69+ }
70+ }
Original file line number Diff line number Diff line change @@ -34,3 +34,26 @@ func TestComparePriority(t *testing.T) {
3434 }
3535 }
3636}
37+
38+ func TestSeverityToPriority (t * testing.T ) {
39+ tests := []struct {
40+ name string
41+ severity string
42+ want string
43+ }{
44+ {"Critical to Urgent" , SeverityCritical , PriorityUrgent },
45+ {"High to Important" , SeverityHigh , PriorityImportant },
46+ {"Medium to Important" , SeverityMedium , PriorityImportant },
47+ {"Low to Informational" , SeverityLow , PriorityInformational },
48+ {"Unknown to Informational" , SeverityUnknown , PriorityInformational },
49+ {"Empty to Informational" , "" , PriorityInformational },
50+ }
51+
52+ for _ , tt := range tests {
53+ t .Run (tt .name , func (t * testing.T ) {
54+ if got := SeverityToPriority (tt .severity ); got != tt .want {
55+ t .Errorf ("SeverityToPriority() = %v, want %v" , got , tt .want )
56+ }
57+ })
58+ }
59+ }
You can’t perform that action at this time.
0 commit comments