@@ -325,6 +325,96 @@ func TestRepositoryProcessor_ProcessRepository_NoCleanMode(t *testing.T) {
325325 }
326326}
327327
328+ func TestRepositoryProcessor_ProcessRepository_NoCleanModeWithFetchAllDisabled (t * testing.T ) {
329+ defer UnsetEnv ("GHORG_" )()
330+ os .Setenv ("GHORG_NO_CLEAN" , "true" )
331+ os .Setenv ("GHORG_FETCH_ALL" , "false" )
332+
333+ // Set up temporary directory with existing repo
334+ dir , err := os .MkdirTemp ("" , "ghorg_test_no_clean_fetch_all_disabled" )
335+ if err != nil {
336+ t .Fatal (err )
337+ }
338+ defer os .RemoveAll (dir )
339+
340+ outputDirAbsolutePath = dir
341+
342+ // Create existing repo directory
343+ repoDir := filepath .Join (dir , "test-repo" )
344+ err = os .MkdirAll (repoDir , 0755 )
345+ if err != nil {
346+ t .Fatal (err )
347+ }
348+
349+ mockGit := NewExtendedMockGit ()
350+ processor := NewRepositoryProcessor (mockGit )
351+
352+ repo := scm.Repo {
353+ Name : "test-repo" ,
354+ URL : "https://github.com/org/test-repo" ,
355+ CloneBranch : "main" ,
356+ HostPath : repoDir ,
357+ }
358+
359+ repoNameWithCollisions := make (map [string ]bool )
360+ processor .ProcessRepository (& repo , repoNameWithCollisions , false , "test-repo" , 0 )
361+
362+ stats := processor .GetStats ()
363+ // In no-clean mode with fetch-all disabled, we should still process successfully
364+ if stats .PulledCount != 1 {
365+ t .Errorf ("Expected pulled count to be 1, got %d" , stats .PulledCount )
366+ }
367+ // Should not have any errors since fetch-all is skipped when disabled
368+ if len (stats .CloneErrors ) != 0 {
369+ t .Errorf ("Expected no errors when FETCH_ALL is disabled, got %d errors: %v" , len (stats .CloneErrors ), stats .CloneErrors )
370+ }
371+ }
372+
373+ func TestRepositoryProcessor_ProcessRepository_NoCleanModeWithFetchAllEnabled (t * testing.T ) {
374+ defer UnsetEnv ("GHORG_" )()
375+ os .Setenv ("GHORG_NO_CLEAN" , "true" )
376+ os .Setenv ("GHORG_FETCH_ALL" , "true" )
377+
378+ // Set up temporary directory with existing repo
379+ dir , err := os .MkdirTemp ("" , "ghorg_test_no_clean_fetch_all_enabled" )
380+ if err != nil {
381+ t .Fatal (err )
382+ }
383+ defer os .RemoveAll (dir )
384+
385+ outputDirAbsolutePath = dir
386+
387+ // Create existing repo directory
388+ repoDir := filepath .Join (dir , "test-repo" )
389+ err = os .MkdirAll (repoDir , 0755 )
390+ if err != nil {
391+ t .Fatal (err )
392+ }
393+
394+ mockGit := NewExtendedMockGit ()
395+ processor := NewRepositoryProcessor (mockGit )
396+
397+ repo := scm.Repo {
398+ Name : "test-repo" ,
399+ URL : "https://github.com/org/test-repo" ,
400+ CloneBranch : "main" ,
401+ HostPath : repoDir ,
402+ }
403+
404+ repoNameWithCollisions := make (map [string ]bool )
405+ processor .ProcessRepository (& repo , repoNameWithCollisions , false , "test-repo" , 0 )
406+
407+ stats := processor .GetStats ()
408+ // In no-clean mode with fetch-all enabled, we should still process successfully
409+ if stats .PulledCount != 1 {
410+ t .Errorf ("Expected pulled count to be 1, got %d" , stats .PulledCount )
411+ }
412+ // Should not have any errors since fetch-all is enabled and mocked
413+ if len (stats .CloneErrors ) != 0 {
414+ t .Errorf ("Expected no errors when FETCH_ALL is enabled, got %d errors: %v" , len (stats .CloneErrors ), stats .CloneErrors )
415+ }
416+ }
417+
328418func TestRepositoryProcessor_ProcessRepository_NameCollisions (t * testing.T ) {
329419 defer UnsetEnv ("GHORG_" )()
330420
0 commit comments