databricks-cli/cmd/fs/helpers_test.go

39 lines
997 B
Go
Raw Normal View History

2023-06-05 12:01:06 +00:00
package fs
2023-06-04 23:34:28 +00:00
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestResolveDbfsPath(t *testing.T) {
2023-06-05 12:01:06 +00:00
path, err := resolveDbfsPath("dbfs:/")
2023-06-04 23:34:28 +00:00
assert.NoError(t, err)
assert.Equal(t, "/", path)
2023-06-05 12:01:06 +00:00
path, err = resolveDbfsPath("dbfs:/abc")
2023-06-04 23:34:28 +00:00
assert.NoError(t, err)
assert.Equal(t, "/abc", path)
2023-06-05 12:01:06 +00:00
path, err = resolveDbfsPath("dbfs:/a/b/c")
2023-06-04 23:34:28 +00:00
assert.NoError(t, err)
assert.Equal(t, "/a/b/c", path)
2023-06-05 12:01:06 +00:00
path, err = resolveDbfsPath("dbfs:/a/b/.")
2023-06-04 23:34:28 +00:00
assert.NoError(t, err)
assert.Equal(t, "/a/b/.", path)
2023-06-05 12:01:06 +00:00
path, err = resolveDbfsPath("dbfs:/a/../c")
2023-06-04 23:34:28 +00:00
assert.NoError(t, err)
assert.Equal(t, "/a/../c", path)
2023-06-05 12:01:06 +00:00
_, err = resolveDbfsPath("dbf:/a/b/c")
2023-06-04 23:34:28 +00:00
assert.ErrorContains(t, err, "expected dbfs path (with the dbfs:/ prefix): dbf:/a/b/c")
2023-06-05 12:01:06 +00:00
_, err = resolveDbfsPath("/a/b/c")
2023-06-04 23:34:28 +00:00
assert.ErrorContains(t, err, "expected dbfs path (with the dbfs:/ prefix): /a/b/c")
2023-06-05 00:13:28 +00:00
2023-06-05 12:01:06 +00:00
_, err = resolveDbfsPath("dbfs:a/b/c")
2023-06-05 00:13:28 +00:00
assert.ErrorContains(t, err, "expected dbfs path (with the dbfs:/ prefix): dbfs:a/b/c")
2023-06-04 23:34:28 +00:00
}