@@ -373,152 +373,3 @@ func Test_setProgressCompleteWithRepo(t *testing.T) {
373
373
}
374
374
}
375
375
}
376
-
377
- func Test_removeRepoFromResumeInfo (t * testing.T ) {
378
- tests := []struct {
379
- startingResumeInfoSlice []string
380
- repoURL string
381
- wantResumeInfoSlice []string
382
- }{
383
- {
384
- startingResumeInfoSlice : []string {"a" , "b" , "c" },
385
- repoURL : "a" ,
386
- wantResumeInfoSlice : []string {"b" , "c" },
387
- },
388
- {
389
- startingResumeInfoSlice : []string {"a" , "b" , "c" },
390
- repoURL : "b" ,
391
- wantResumeInfoSlice : []string {"a" , "c" },
392
- },
393
- { // This is the probably can't happen case of a repo not in the list.
394
- startingResumeInfoSlice : []string {"a" , "b" , "c" },
395
- repoURL : "not in the list" ,
396
- wantResumeInfoSlice : []string {"a" , "b" , "c" },
397
- },
398
- }
399
-
400
- logger := logrus .New ()
401
- logger .Out = io .Discard
402
- s := & Source {
403
- repos : []string {},
404
- log : logger .WithField ("no" , "output" ),
405
- }
406
-
407
- for _ , tt := range tests {
408
- s .resumeInfoSlice = tt .startingResumeInfoSlice
409
- s .removeRepoFromResumeInfo (tt .repoURL )
410
- if ! reflect .DeepEqual (s .resumeInfoSlice , tt .wantResumeInfoSlice ) {
411
- t .Errorf ("s.removeRepoFromResumeInfo() got: %v, want: %v" , s .resumeInfoSlice , tt .wantResumeInfoSlice )
412
- }
413
- }
414
- }
415
-
416
- func Test_encodeResumeInfo (t * testing.T ) {
417
- tests := []struct {
418
- startingResumeInfoSlice []string
419
- wantEncodedResumeInfo string
420
- }{
421
- {
422
- startingResumeInfoSlice : []string {"a" , "b" , "c" },
423
- wantEncodedResumeInfo : "a\t b\t c" ,
424
- },
425
- {
426
- startingResumeInfoSlice : []string {},
427
- wantEncodedResumeInfo : "" ,
428
- },
429
- }
430
-
431
- logger := logrus .New ()
432
- logger .Out = io .Discard
433
- s := & Source {
434
- repos : []string {},
435
- log : logger .WithField ("no" , "output" ),
436
- }
437
-
438
- for _ , tt := range tests {
439
- s .resumeInfoSlice = tt .startingResumeInfoSlice
440
- gotEncodedResumeInfo := s .encodeResumeInfo ()
441
- if gotEncodedResumeInfo != tt .wantEncodedResumeInfo {
442
- t .Errorf ("s.encodeResumeInfo() got: %q, want: %q" , gotEncodedResumeInfo , tt .wantEncodedResumeInfo )
443
- }
444
- }
445
- }
446
-
447
- func Test_decodeResumeInfo (t * testing.T ) {
448
- tests := []struct {
449
- resumeInfo string
450
- wantResumeInfoSlice []string
451
- }{
452
- {
453
- resumeInfo : "a\t b\t c" ,
454
- wantResumeInfoSlice : []string {"a" , "b" , "c" },
455
- },
456
- {
457
- resumeInfo : "" ,
458
- wantResumeInfoSlice : nil ,
459
- },
460
- }
461
-
462
- for _ , tt := range tests {
463
- s := & Source {}
464
- s .decodeResumeInfo (tt .resumeInfo )
465
- if ! reflect .DeepEqual (s .resumeInfoSlice , tt .wantResumeInfoSlice ) {
466
- t .Errorf ("s.decodeResumeInfo() got: %v, want: %v" , s .resumeInfoSlice , tt .wantResumeInfoSlice )
467
- }
468
- }
469
- }
470
-
471
- func Test_filterReposToResume (t * testing.T ) {
472
- startingRepos := []string {"a" , "b" , "c" , "d" , "e" , "f" , "g" }
473
-
474
- tests := map [string ]struct {
475
- resumeInfo string
476
- wantProgressOffsetCount int
477
- wantReposToScan []string
478
- }{
479
- "blank resume info" : {
480
- resumeInfo : "" ,
481
- wantProgressOffsetCount : 0 ,
482
- wantReposToScan : startingRepos ,
483
- },
484
- "starting repos" : {
485
- resumeInfo : "a\t b" ,
486
- wantProgressOffsetCount : 0 ,
487
- wantReposToScan : startingRepos ,
488
- },
489
- "early contiguous repos" : {
490
- resumeInfo : "b\t c" ,
491
- wantProgressOffsetCount : 1 ,
492
- wantReposToScan : []string {"b" , "c" , "d" , "e" , "f" , "g" },
493
- },
494
- "non-contiguous repos" : {
495
- resumeInfo : "b\t e" ,
496
- wantProgressOffsetCount : 3 ,
497
- wantReposToScan : []string {"b" , "e" , "f" , "g" },
498
- },
499
- "no repos found in the repo list" : {
500
- resumeInfo : "not\t there" ,
501
- wantProgressOffsetCount : 0 ,
502
- wantReposToScan : startingRepos ,
503
- },
504
- "only some repos in the list" : {
505
- resumeInfo : "c\t not\t there" ,
506
- wantProgressOffsetCount : 2 ,
507
- wantReposToScan : []string {"c" , "d" , "e" , "f" , "g" },
508
- },
509
- }
510
-
511
- for name , tt := range tests {
512
- s := & Source {
513
- repos : startingRepos ,
514
- }
515
-
516
- gotProgressOffsetCount := s .filterReposToResume (tt .resumeInfo )
517
- if gotProgressOffsetCount != tt .wantProgressOffsetCount {
518
- t .Errorf ("s.filterReposToResume() name: %q got: %d, want: %d" , name , gotProgressOffsetCount , tt .wantProgressOffsetCount )
519
- }
520
- if ! reflect .DeepEqual (s .repos , tt .wantReposToScan ) {
521
- t .Errorf ("s.filterReposToResume() name: %q got: %v, want: %v" , name , s .repos , tt .wantReposToScan )
522
- }
523
- }
524
- }
0 commit comments