(t *testing.T)
| 482 | } |
| 483 | |
| 484 | func TestMigratingFile(t *testing.T) { |
| 485 | sourceFile, _ := ioutil.TempFile("", "") |
| 486 | defer os.Remove(sourceFile.Name()) |
| 487 | destinationFile, _ := ioutil.TempFile("", "") |
| 488 | // delete the file so that we'll write to it |
| 489 | os.Remove(destinationFile.Name()) |
| 490 | |
| 491 | WriteToFile(testConfigAlfa, sourceFile.Name()) |
| 492 | |
| 493 | loadingRules := ClientConfigLoadingRules{ |
| 494 | MigrationRules: map[string]string{destinationFile.Name(): sourceFile.Name()}, |
| 495 | } |
| 496 | |
| 497 | if _, err := loadingRules.Load(); err != nil { |
| 498 | t.Errorf("unexpected error %v", err) |
| 499 | } |
| 500 | |
| 501 | // the load should have recreated this file |
| 502 | defer os.Remove(destinationFile.Name()) |
| 503 | |
| 504 | sourceContent, err := ioutil.ReadFile(sourceFile.Name()) |
| 505 | if err != nil { |
| 506 | t.Errorf("unexpected error %v", err) |
| 507 | } |
| 508 | destinationContent, err := ioutil.ReadFile(destinationFile.Name()) |
| 509 | if err != nil { |
| 510 | t.Errorf("unexpected error %v", err) |
| 511 | } |
| 512 | |
| 513 | if !reflect.DeepEqual(sourceContent, destinationContent) { |
| 514 | t.Errorf("source and destination do not match") |
| 515 | } |
| 516 | } |
| 517 | |
| 518 | func TestMigratingFileLeaveExistingFileAlone(t *testing.T) { |
| 519 | sourceFile, _ := ioutil.TempFile("", "") |
nothing calls this directly
no test coverage detected