added test for ls on flie

This commit is contained in:
Shreyas Goenka 2023-06-05 01:20:54 +02:00
parent 2706bebb38
commit 6b667b5e01
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
1 changed files with 23 additions and 0 deletions

View File

@ -4,6 +4,8 @@ import (
"context"
"encoding/json"
"io/fs"
"path"
"regexp"
"strings"
"testing"
@ -48,6 +50,27 @@ func TestFsLsForDbfs(t *testing.T) {
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) {
t.Log(GetEnvOrSkipTest(t, "CLOUD_ENV"))