MCPcopy Create free account
hub / github.com/auth0/auth0-cli / TestCleanOutputDirectory

Function TestCleanOutputDirectory

internal/cli/terraform_test.go:416–461  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

414}
415
416func 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
463func TestTerraformInputs_ParseResourceFetchers(t *testing.T) {
464 api := &auth0.API{}

Callers

nothing calls this directly

Calls 2

cleanOutputDirectoryFunction · 0.85
CreateMethod · 0.65

Tested by

no test coverage detected