@@ -572,11 +572,11 @@ func TestMakeInstallFunction(t *testing.T) {
572572 fi , _ := f .Stat ()
573573 f .Close ()
574574
575- // Test 1: Conflict without force -> Error
575+ // Test 1: Conflict without force -> Success by default
576576 fnBlock := makeInstallFunction (srcDir , dstDir , make (map [string ]string ), false , false , cm )
577577 errBlock := fnBlock (filepath .Join (srcDir , "conflicting_file" ), fi , nil )
578- if errBlock = = nil {
579- t .Errorf ("expected conflict error, got nil" )
578+ if errBlock ! = nil {
579+ t .Errorf ("expected no conflict error by default , got %v" , errBlock )
580580 }
581581
582582 // Test 2: Conflict with force -> Success
@@ -585,4 +585,20 @@ func TestMakeInstallFunction(t *testing.T) {
585585 if errForce != nil {
586586 t .Errorf ("expected no error with force, got %v" , errForce )
587587 }
588+
589+ // Test 3: Conflict without force in strict mode -> Error
590+ settings .StrictConflicts = true
591+ defer func () { settings .StrictConflicts = false }()
592+ fnStrict := makeInstallFunction (srcDir , dstDir , make (map [string ]string ), false , false , cm )
593+ errStrict := fnStrict (filepath .Join (srcDir , "conflicting_file" ), fi , nil )
594+ if errStrict == nil {
595+ t .Errorf ("expected conflict error in strict mode, got nil" )
596+ }
597+
598+ // Test 4: Conflict with force in strict mode -> Success
599+ fnStrictForce := makeInstallFunction (srcDir , dstDir , make (map [string ]string ), false , true , cm )
600+ errStrictForce := fnStrictForce (filepath .Join (srcDir , "conflicting_file" ), fi , nil )
601+ if errStrictForce != nil {
602+ t .Errorf ("expected no error with force in strict mode, got %v" , errStrictForce )
603+ }
588604}
0 commit comments