Skip to content

Commit

Permalink
Fix TestAccFsMkdirWhenFileExistsAtPath in isolated azure environments
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas-goenka committed Oct 16, 2024
1 parent 0753dfe commit 0ae0a71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 3 additions & 2 deletions internal/fs_mkdir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package internal

import (
"context"
"fmt"

Check failure on line 5 in internal/fs_mkdir_test.go

View workflow job for this annotation

GitHub Actions / tests (macos-latest)

"fmt" imported and not used (compile)

Check failure on line 5 in internal/fs_mkdir_test.go

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest)

"fmt" imported and not used (compile)

Check failure on line 5 in internal/fs_mkdir_test.go

View workflow job for this annotation

GitHub Actions / tests (windows-latest)

"fmt" imported and not used (compile)
"path"
"regexp"
"strings"
Expand Down Expand Up @@ -112,8 +113,8 @@ func TestAccFsMkdirWhenFileExistsAtPath(t *testing.T) {
// assert mkdir fails
_, _, err = RequireErrorRun(t, "fs", "mkdir", path.Join(tmpDir, "hello"))

// Different cloud providers return different errors.
regex := regexp.MustCompile(`(^|: )Path is a file: .*$|(^|: )Cannot create directory .* because .* is an existing file\.$|(^|: )mkdirs\(hadoopPath: .*, permission: rwxrwxrwx\): failed$`)
// Different cloud providers or cloud configurations return different errors.
regex := regexp.MustCompile(`(^|: )Path is a file: .*$|(^|: )Cannot create directory .* because .* is an existing file\.$|(^|: )mkdirs\(hadoopPath: .*, permission: rwxrwxrwx\): failed$|(^|: )"The specified path already exists.".*$`)
assert.Regexp(t, regex, err.Error())
})

Expand Down
10 changes: 4 additions & 6 deletions internal/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"time"

"github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/internal/acc"
"github.com/databricks/cli/libs/flags"

"github.com/databricks/cli/cmd"
Expand Down Expand Up @@ -591,13 +592,10 @@ func setupWsfsExtensionsFiler(t *testing.T) (filer.Filer, string) {
}

func setupDbfsFiler(t *testing.T) (filer.Filer, string) {

Check failure on line 594 in internal/helpers.go

View workflow job for this annotation

GitHub Actions / tests (macos-latest)

func setupDbfsFiler is unused (U1000)

Check failure on line 594 in internal/helpers.go

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest)

func setupDbfsFiler is unused (U1000)

Check failure on line 594 in internal/helpers.go

View workflow job for this annotation

GitHub Actions / tests (windows-latest)

func setupDbfsFiler is unused (U1000)
t.Log(GetEnvOrSkipTest(t, "CLOUD_ENV"))

w, err := databricks.NewWorkspaceClient()
require.NoError(t, err)
_, wt := acc.WorkspaceTest(t)

tmpDir := TemporaryDbfsDir(t, w)
f, err := filer.NewDbfsClient(w, tmpDir)
tmpDir := TemporaryDbfsDir(t, wt.W)
f, err := filer.NewDbfsClient(wt.W, tmpDir)
require.NoError(t, err)

return f, path.Join("dbfs:/", tmpDir)
Expand Down

0 comments on commit 0ae0a71

Please sign in to comment.