This repository was archived by the owner on Sep 9, 2020. It is now read-only.
File tree 1 file changed +57
-0
lines changed
1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -230,3 +230,60 @@ func TestBasicStatusGetConsolidatedVersion(t *testing.T) {
230
230
})
231
231
}
232
232
}
233
+
234
+ func TestBasicStatusGetConsolidatedLatest (t * testing.T ) {
235
+ testCases := []struct {
236
+ name string
237
+ basicStatus BasicStatus
238
+ revSize int
239
+ wantLatest string
240
+ }{
241
+ {
242
+ name : "empty BasicStatus" ,
243
+ basicStatus : BasicStatus {},
244
+ revSize : shortRev ,
245
+ wantLatest : "" ,
246
+ },
247
+ {
248
+ name : "nil latest" ,
249
+ basicStatus : BasicStatus {
250
+ Latest : nil ,
251
+ },
252
+ revSize : shortRev ,
253
+ wantLatest : "" ,
254
+ },
255
+ {
256
+ name : "with error" ,
257
+ basicStatus : BasicStatus {
258
+ hasError : true ,
259
+ },
260
+ revSize : shortRev ,
261
+ wantLatest : "unknown" ,
262
+ },
263
+ {
264
+ name : "short latest" ,
265
+ basicStatus : BasicStatus {
266
+ Latest : gps .Revision ("adummylonglongrevision" ),
267
+ },
268
+ revSize : shortRev ,
269
+ wantLatest : "adummyl" ,
270
+ },
271
+ {
272
+ name : "long latest" ,
273
+ basicStatus : BasicStatus {
274
+ Latest : gps .Revision ("adummylonglongrevision" ),
275
+ },
276
+ revSize : longRev ,
277
+ wantLatest : "adummylonglongrevision" ,
278
+ },
279
+ }
280
+
281
+ for _ , tc := range testCases {
282
+ t .Run (tc .name , func (t * testing.T ) {
283
+ gotRev := tc .basicStatus .getConsolidatedLatest (tc .revSize )
284
+ if gotRev != tc .wantLatest {
285
+ t .Errorf ("unexpected consolidated latest: \n \t (GOT) %v \n \t (WNT) %v" , gotRev , tc .wantLatest )
286
+ }
287
+ })
288
+ }
289
+ }
You can’t perform that action at this time.
0 commit comments