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

Function TestCheckOutputDirectoryIsEmpty

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

Source from the content-addressed store, hash-verified

375}
376
377func TestCheckOutputDirectoryIsEmpty(t *testing.T) {
378 t.Run("it returns true if the directory is empty", func(t *testing.T) {
379 tempDIR := t.TempDir()
380
381 isEmpty := checkOutputDirectoryIsEmpty(&cli{}, &cobra.Command{}, tempDIR)
382 assert.True(t, isEmpty)
383 })
384
385 t.Run("it returns true if the directory doesn't exist", func(t *testing.T) {
386 isEmpty := checkOutputDirectoryIsEmpty(&cli{}, &cobra.Command{}, "")
387 assert.True(t, isEmpty)
388 })
389
390 t.Run("it returns true if the directory is not empty but we're forcing the command", func(t *testing.T) {
391 tempDIR := t.TempDir()
392 files := []string{"auth0_main.tf", "auth0_import.tf", "auth0_generated.tf"}
393
394 for _, file := range files {
395 filePath := path.Join(tempDIR, file)
396 _, err := os.Create(filePath)
397 require.NoError(t, err)
398 }
399
400 stdout := &bytes.Buffer{}
401 cli := &cli{
402 renderer: &display.Renderer{
403 MessageWriter: stdout,
404 ResultWriter: stdout,
405 },
406 force: true,
407 noInput: true,
408 }
409
410 isEmpty := checkOutputDirectoryIsEmpty(cli, &cobra.Command{}, tempDIR)
411 assert.True(t, isEmpty)
412 assert.Contains(t, stdout.String(), "Proceeding will overwrite the auth0_main.tf, auth0_import.tf and auth0_generated.tf files.")
413 })
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) {

Callers

nothing calls this directly

Calls 2

CreateMethod · 0.65

Tested by

no test coverage detected