(t *testing.T)
| 414 | } |
| 415 | |
| 416 | func TestCleanOutputDirectory(t *testing.T) { |
| 417 | t.Run("it can successfully clean the output directory from all generated files", func(t *testing.T) { |
| 418 | tempDIR := t.TempDir() |
| 419 | files := []string{"auth0_main.tf", "auth0_import.tf", "auth0_generated.tf"} |
| 420 | |
| 421 | for _, file := range files { |
| 422 | filePath := path.Join(tempDIR, file) |
| 423 | _, err := os.Create(filePath) |
| 424 | require.NoError(t, err) |
| 425 | } |
| 426 | |
| 427 | err := cleanOutputDirectory(tempDIR) |
| 428 | assert.NoError(t, err) |
| 429 | |
| 430 | for _, file := range files { |
| 431 | filePath := path.Join(tempDIR, file) |
| 432 | _, err := os.Stat(filePath) |
| 433 | assert.ErrorContains(t, err, "no such file or directory") |
| 434 | } |
| 435 | }) |
| 436 | |
| 437 | t.Run("it returns an error if it can't remove a file", func(t *testing.T) { |
| 438 | files := []string{"auth0_main.tf", "auth0_import.tf", "auth0_generated.tf"} |
| 439 | |
| 440 | for _, file := range files { |
| 441 | t.Run(file, func(t *testing.T) { |
| 442 | tempDIR := t.TempDir() |
| 443 | |
| 444 | filePath := path.Join(tempDIR, file) |
| 445 | _, err := os.Create(filePath) |
| 446 | require.NoError(t, err) |
| 447 | |
| 448 | err = os.Chmod(tempDIR, 0444) |
| 449 | require.NoError(t, err) |
| 450 | |
| 451 | t.Cleanup(func() { |
| 452 | err = os.Chmod(tempDIR, 0755) |
| 453 | require.NoError(t, err) |
| 454 | }) |
| 455 | |
| 456 | err = cleanOutputDirectory(tempDIR) |
| 457 | assert.ErrorContains(t, err, "permission denied") |
| 458 | }) |
| 459 | } |
| 460 | }) |
| 461 | } |
| 462 | |
| 463 | func TestTerraformInputs_ParseResourceFetchers(t *testing.T) { |
| 464 | api := &auth0.API{} |
nothing calls this directly
no test coverage detected