2024-12-13 14:38:58 +00:00
|
|
|
package fs_test
|
2022-09-14 15:50:29 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2024-02-20 16:14:37 +00:00
|
|
|
"path"
|
2022-10-10 08:27:45 +00:00
|
|
|
"path/filepath"
|
|
|
|
|
2024-12-17 07:45:58 +00:00
|
|
|
"github.com/databricks/cli/integration/internal/acc"
|
2024-12-12 12:35:38 +00:00
|
|
|
"github.com/databricks/cli/internal/testutil"
|
2024-07-10 06:38:06 +00:00
|
|
|
|
2024-02-20 16:14:37 +00:00
|
|
|
"github.com/databricks/cli/libs/filer"
|
2022-10-10 08:27:45 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2022-09-14 15:50:29 +00:00
|
|
|
)
|
|
|
|
|
2024-12-12 14:42:15 +00:00
|
|
|
func setupLocalFiler(t testutil.TestingT) (filer.Filer, string) {
|
2024-02-20 16:14:37 +00:00
|
|
|
tmp := t.TempDir()
|
|
|
|
f, err := filer.NewLocalClient(tmp)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
return f, path.Join(filepath.ToSlash(tmp))
|
|
|
|
}
|
|
|
|
|
2024-12-12 14:42:15 +00:00
|
|
|
func setupDbfsFiler(t testutil.TestingT) (filer.Filer, string) {
|
2024-10-16 12:50:17 +00:00
|
|
|
_, wt := acc.WorkspaceTest(t)
|
2024-02-20 16:14:37 +00:00
|
|
|
|
2024-12-12 21:28:04 +00:00
|
|
|
tmpdir := acc.TemporaryDbfsDir(wt)
|
|
|
|
f, err := filer.NewDbfsClient(wt.W, tmpdir)
|
2024-02-20 16:14:37 +00:00
|
|
|
require.NoError(t, err)
|
2024-12-12 21:28:04 +00:00
|
|
|
return f, path.Join("dbfs:/", tmpdir)
|
2024-02-20 16:14:37 +00:00
|
|
|
}
|
|
|
|
|
2024-12-12 14:42:15 +00:00
|
|
|
func setupUcVolumesFiler(t testutil.TestingT) (filer.Filer, string) {
|
2024-12-12 21:28:04 +00:00
|
|
|
_, wt := acc.WorkspaceTest(t)
|
2024-02-20 16:14:37 +00:00
|
|
|
|
|
|
|
if os.Getenv("TEST_METASTORE_ID") == "" {
|
|
|
|
t.Skip("Skipping tests that require a UC Volume when metastore id is not set.")
|
|
|
|
}
|
|
|
|
|
2024-12-12 21:28:04 +00:00
|
|
|
tmpdir := acc.TemporaryVolume(wt)
|
|
|
|
f, err := filer.NewFilesClient(wt.W, tmpdir)
|
2024-02-20 16:14:37 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2024-12-12 21:28:04 +00:00
|
|
|
return f, path.Join("dbfs:/", tmpdir)
|
2024-02-20 16:14:37 +00:00
|
|
|
}
|