mirror of https://github.com/databricks/cli.git
added test for ls on flie
This commit is contained in:
parent
2706bebb38
commit
6b667b5e01
|
@ -4,6 +4,8 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
"path"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -48,6 +50,27 @@ func TestFsLsForDbfs(t *testing.T) {
|
||||||
assert.Equal(t, float64(3), parsedStdout[1]["size"])
|
assert.Equal(t, float64(3), parsedStdout[1]["size"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFsLsForDbfsOnFile(t *testing.T) {
|
||||||
|
t.Log(GetEnvOrSkipTest(t, "CLOUD_ENV"))
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
|
w, err := databricks.NewWorkspaceClient()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
tmpDir := temporaryDbfsDir(t, w)
|
||||||
|
|
||||||
|
f, err := filer.NewDbfsClient(w, tmpDir)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
err = f.Mkdir(ctx, "a")
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = f.Write(ctx, "a/hello.txt", strings.NewReader("abc"), filer.CreateParentDirectories)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
_, _, err = RequireErrorRun(t, "fs", "ls", "dbfs:"+path.Join(tmpDir, "a", "hello.txt"), "--output=json")
|
||||||
|
assert.Regexp(t, regexp.MustCompile("not a directory: .*/a/hello.txt"), err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
func TestFsLsForDbfsOnEmptyDir(t *testing.T) {
|
func TestFsLsForDbfsOnEmptyDir(t *testing.T) {
|
||||||
t.Log(GetEnvOrSkipTest(t, "CLOUD_ENV"))
|
t.Log(GetEnvOrSkipTest(t, "CLOUD_ENV"))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue