@@ -47,18 +47,19 @@ func marshalOrDie(obj interface{}, t *testing.T) []byte {
4747}
4848
4949func genMockGCSListResponse (files ... string ) []byte {
50- resptemplate := "{\" items\" :[%s]}"
51- itemTempalte := "{\" name\" :\" %s\" }"
50+ respTemplate := "{\" items\" :[%s]}"
51+ itemTemplate := "{\" name\" :\" %s\" }"
5252 items := []string {}
5353 for _ , file := range files {
54- items = append (items , fmt .Sprintf (itemTempalte , file ))
54+ items = append (items , fmt .Sprintf (itemTemplate , file ))
5555 }
56- return []byte (fmt .Sprintf (resptemplate , strings .Join (items , "," )))
56+ return []byte (fmt .Sprintf (respTemplate , strings .Join (items , "," )))
5757}
5858
5959func TestCheckGCSBuilds (t * testing.T ) {
6060 latestBuildNumberFoo := 42
6161 latestBuildNumberBar := 44
62+ latestBuildNumberBaz := 99
6263 tests := []struct {
6364 paths map [string ][]byte
6465 expectStable bool
@@ -77,12 +78,18 @@ func TestCheckGCSBuilds(t *testing.T) {
7778 Result : "SUCCESS" ,
7879 Timestamp : 1234 ,
7980 }, t ),
81+ "/baz/latest-build.txt" : []byte (strconv .Itoa (latestBuildNumberBaz )),
82+ fmt .Sprintf ("/baz/%v/finished.json" , latestBuildNumberBaz ): marshalOrDie (utils.FinishedFile {
83+ Result : "UNSTABLE" ,
84+ Timestamp : 1234 ,
85+ }, t ),
8086 "/" : genMockGCSListResponse (),
8187 },
8288 expectStable : true ,
8389 expectedStatus : map [string ]BuildInfo {
8490 "foo" : {Status : "Stable" , ID : "42" },
8591 "bar" : {Status : "Stable" , ID : "44" },
92+ "baz" : {Status : "[nonblocking] Not Stable" , ID : "99" },
8693 },
8794 },
8895 {
@@ -97,12 +104,18 @@ func TestCheckGCSBuilds(t *testing.T) {
97104 Result : "UNSTABLE" ,
98105 Timestamp : 1234 ,
99106 }, t ),
107+ "/baz/latest-build.txt" : []byte (strconv .Itoa (latestBuildNumberBaz )),
108+ fmt .Sprintf ("/baz/%v/finished.json" , latestBuildNumberBaz ): marshalOrDie (utils.FinishedFile {
109+ Result : "SUCCESS" ,
110+ Timestamp : 1234 ,
111+ }, t ),
100112 "/" : genMockGCSListResponse (),
101113 },
102114 expectStable : false ,
103115 expectedStatus : map [string ]BuildInfo {
104116 "foo" : {Status : "Stable" , ID : "42" },
105117 "bar" : {Status : "Not Stable" , ID : "44" },
118+ "baz" : {Status : "[nonblocking] Stable" , ID : "99" },
106119 },
107120 },
108121 {
@@ -140,6 +153,7 @@ func TestCheckGCSBuilds(t *testing.T) {
140153 expectedStatus : map [string ]BuildInfo {
141154 "foo" : {Status : "Stable" , ID : "42" },
142155 "bar" : {Status : "Ignorable flake" , ID : "44" },
156+ "baz" : {Status : "[nonblocking] Not Stable" , ID : "-1" },
143157 },
144158 },
145159 {
@@ -177,6 +191,7 @@ func TestCheckGCSBuilds(t *testing.T) {
177191 expectedStatus : map [string ]BuildInfo {
178192 "foo" : {Status : "Stable" , ID : "42" },
179193 "bar" : {Status : "Ignorable flake" , ID : "44" },
194+ "baz" : {Status : "[nonblocking] Not Stable" , ID : "-1" },
180195 },
181196 },
182197 {
@@ -214,6 +229,7 @@ func TestCheckGCSBuilds(t *testing.T) {
214229 expectedStatus : map [string ]BuildInfo {
215230 "foo" : {Status : "Stable" , ID : "42" },
216231 "bar" : {Status : "Not Stable" , ID : "44" },
232+ "baz" : {Status : "[nonblocking] Not Stable" , ID : "-1" },
217233 },
218234 },
219235
@@ -235,6 +251,7 @@ func TestCheckGCSBuilds(t *testing.T) {
235251 expectedStatus : map [string ]BuildInfo {
236252 "foo" : {Status : "Stable" , ID : "42" },
237253 "bar" : {Status : "Not Stable" , ID : "44" },
254+ "baz" : {Status : "[nonblocking] Not Stable" , ID : "-1" },
238255 },
239256 },
240257 {
@@ -255,6 +272,7 @@ func TestCheckGCSBuilds(t *testing.T) {
255272 expectedStatus : map [string ]BuildInfo {
256273 "foo" : {Status : "Not Stable" , ID : "42" },
257274 "bar" : {Status : "Not Stable" , ID : "44" },
275+ "baz" : {Status : "[nonblocking] Not Stable" , ID : "-1" },
258276 },
259277 },
260278 {
@@ -275,6 +293,7 @@ func TestCheckGCSBuilds(t *testing.T) {
275293 expectedStatus : map [string ]BuildInfo {
276294 "foo" : {Status : "Not Stable" , ID : "42" },
277295 "bar" : {Status : "Stable" , ID : "44" },
296+ "baz" : {Status : "[nonblocking] Not Stable" , ID : "-1" },
278297 },
279298 },
280299 }
@@ -296,6 +315,9 @@ func TestCheckGCSBuilds(t *testing.T) {
296315 "foo" ,
297316 "bar" ,
298317 },
318+ NonBlockingJobNames : []string {
319+ "baz" ,
320+ },
299321 BuildStatus : map [string ]BuildInfo {},
300322 GoogleGCSBucketUtils : utils .NewTestUtils (server .URL ),
301323 }
0 commit comments