-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathstatuses_test.go
More file actions
106 lines (96 loc) · 2.71 KB
/
Copy pathstatuses_test.go
File metadata and controls
106 lines (96 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package forges
import "testing"
func TestNormalizeIssueState(t *testing.T) {
tests := []struct {
in string
want IssueState
}{
{"open", IssueStateOpen},
{"on_hold", IssueStateOpen},
{"closed", IssueStateClosed},
{"invalid", IssueStateClosed},
{"duplicate", IssueStateClosed},
{"wontfix", IssueStateClosed},
{"unexpected", IssueStateUnknown},
}
for _, tt := range tests {
if got := NormalizeIssueState(tt.in); got != tt.want {
t.Errorf("NormalizeIssueState(%q) = %q, want %q", tt.in, got, tt.want)
}
}
}
func TestNormalizePRStatus(t *testing.T) {
tests := []struct {
in string
want PRStatus
}{
{"open", PRStatusOpen},
{"opened", PRStatusOpen},
{"MERGED", PRStatusMerged},
{"DECLINED", PRStatusClosed},
{"superseded", PRStatusClosed},
{"unexpected", PRStatusUnknown},
}
for _, tt := range tests {
if got := NormalizePRStatus(tt.in); got != tt.want {
t.Errorf("NormalizePRStatus(%q) = %q, want %q", tt.in, got, tt.want)
}
}
}
func TestNormalizeCommitStatusState(t *testing.T) {
tests := []struct {
in string
want CommitStatusState
}{
{"success", CommitStatusSuccess},
{"passing", CommitStatusSuccess},
{"approved", CommitStatusSuccess},
{"failed", CommitStatusFailure},
{"in_progress", CommitStatusPending},
{"errored", CommitStatusError},
{"canceled", CommitStatusCancelled},
{"unexpected", CommitStatusUnknown},
}
for _, tt := range tests {
if got := NormalizeCommitStatusState(tt.in); got != tt.want {
t.Errorf("NormalizeCommitStatusState(%q) = %q, want %q", tt.in, got, tt.want)
}
}
}
func TestNormalizeAccessLevel(t *testing.T) {
tests := []struct {
in string
want AccessLevel
}{
{"pull", AccessLevelRead},
{"reporter", AccessLevelRead},
{"triage", AccessLevelRead},
{"planner", AccessLevelRead},
{"push", AccessLevelWrite},
{"developer", AccessLevelWrite},
{"maintainer", AccessLevelAdmin},
{"maintain", AccessLevelAdmin},
{"owner", AccessLevelAdmin},
{"", AccessLevelNone},
{"custom", AccessLevelUnknown},
}
for _, tt := range tests {
if got := NormalizeAccessLevel(tt.in); got != tt.want {
t.Errorf("NormalizeAccessLevel(%q) = %q, want %q", tt.in, got, tt.want)
}
}
}
func TestNormalizeCIStatusAndConclusion(t *testing.T) {
if got := NormalizeCIStatus("in_progress"); got != CIStatusRunning {
t.Errorf("NormalizeCIStatus(in_progress) = %q", got)
}
if got := NormalizeCIStatus("canceled"); got != CIStatusCancelled {
t.Errorf("NormalizeCIStatus(canceled) = %q", got)
}
if got := NormalizeCIConclusion("timed-out"); got != CIConclusionTimedOut {
t.Errorf("NormalizeCIConclusion(timed-out) = %q", got)
}
if got := NormalizeCIConclusion(""); got != "" {
t.Errorf("NormalizeCIConclusion(empty) = %q", got)
}
}