FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
stackrox/tools/retest/github_test.go at master · stackrox/stackrox · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
stackrox
/
stackrox
Public
Notifications
You must be signed in to change notification settings
Fork
191
Star
1.3k
Code
Issues
54
Pull requests
603
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
stackrox
/
tools
/
retest
/
github_test.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
79 lines (76 loc) · 1.87 KB
Breadcrumbs
stackrox
/
tools
/
retest
/
github_test.go
Copy path
File metadata and controls
79 lines (76 loc) · 1.87 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package
main
import
(
"testing"
"github.com/google/go-github/v60/github"
"github.com/stretchr/testify/assert"
)
// Test_jobStateMapping checks how parseJobState and checkToState each map
// their own API's raw value — a Statuses API state, or a Checks API
// conclusion — onto the shared jobState type.
func
Test_jobStateMapping
(
t
*
testing.
T
) {
tests
:=
map
[
string
]
struct
{
raw
string
fromCheck
bool
wantState
jobState
}{
"status: success maps to ok"
: {
raw
:
"success"
,
wantState
:
jobOK
,
},
"status: pending maps to pending"
: {
raw
:
"pending"
,
wantState
:
jobPending
,
},
"status: failure maps to failure"
: {
raw
:
"failure"
,
wantState
:
jobFailure
,
},
"status: error maps to failure, since it also warrants a retest"
: {
raw
:
"error"
,
wantState
:
jobFailure
,
},
"status: unknown state falls back to ok"
: {
raw
:
"something-unexpected"
,
wantState
:
jobOK
,
},
"status: empty string falls back to ok"
: {
raw
:
""
,
wantState
:
jobOK
,
},
"check: success maps to ok"
: {
raw
:
"success"
,
fromCheck
:
true
,
wantState
:
jobOK
,
},
"check: failure maps to failure"
: {
raw
:
"failure"
,
fromCheck
:
true
,
wantState
:
jobFailure
,
},
"check: timed_out maps to failure, since it also warrants a retest"
: {
raw
:
"timed_out"
,
fromCheck
:
true
,
wantState
:
jobFailure
,
},
"check: neutral falls back to ok"
: {
raw
:
"neutral"
,
fromCheck
:
true
,
wantState
:
jobOK
,
},
"check: cancelled falls back to ok"
: {
raw
:
"cancelled"
,
fromCheck
:
true
,
wantState
:
jobOK
,
},
}
for
name
,
tt
:=
range
tests
{
t
.
Run
(
name
,
func
(
t
*
testing.
T
) {
if
tt
.
fromCheck
{
check
:=
&
github.
CheckRun
{
Conclusion
:
new
(tt.
raw
)}
assert
.
Equal
(
t
,
tt
.
wantState
,
checkToState
(
check
))
return
}
assert
.
Equal
(
t
,
tt
.
wantState
,
parseJobState
(
tt
.
raw
))
})
}
}
Back
|
FazBrowse Home
|
New Git URL