fix tests

This commit is contained in:
Fabian Jakobs 2024-09-04 10:31:40 +02:00
parent 6585a757bb
commit 62b2451c10
No known key found for this signature in database
3 changed files with 7 additions and 10 deletions

View File

@ -9,9 +9,9 @@ import (
"path/filepath"
"strings"
"github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/libs/env"
"github.com/databricks/cli/libs/filer"
"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/service/workspace"
)
@ -119,10 +119,7 @@ func writeFile(ctx context.Context, path string, content []byte) error {
}
func importNotebook(ctx context.Context, path string, content []byte) error {
w, err := databricks.NewWorkspaceClient()
if err != nil {
return err
}
w := root.WorkspaceClient(ctx)
return w.Workspace.Import(ctx, workspace.Import{
Format: "AUTO",

View File

@ -24,7 +24,7 @@ func testInMemoryFile(t *testing.T, perm fs.FileMode) {
perm: perm,
content: []byte("123"),
}
err := f.PersistToDisk()
err := f.PersistToDisk(context.Background())
assert.NoError(t, err)
assertFileContent(t, filepath.Join(tmpDir, "a/b/c"), "123")
@ -38,9 +38,10 @@ func testCopyFile(t *testing.T, perm fs.FileMode) {
require.NoError(t, err)
err = os.WriteFile(filepath.Join(tmpDir, "source"), []byte("qwerty"), perm)
require.NoError(t, err)
ctx := context.Background()
f := &copyFile{
ctx: context.Background(),
ctx: ctx,
dstPath: &destinationPath{
root: tmpDir,
relPath: "a/b/c",
@ -49,7 +50,7 @@ func testCopyFile(t *testing.T, perm fs.FileMode) {
srcPath: "source",
srcFiler: templateFiler,
}
err = f.PersistToDisk()
err = f.PersistToDisk(ctx)
assert.NoError(t, err)
assertFileContent(t, filepath.Join(tmpDir, "a/b/c"), "qwerty")

View File

@ -313,8 +313,7 @@ func (r *renderer) persistToDisk() error {
_, err := os.Stat(path)
if err == nil {
return fmt.Errorf("failed to initialize template, one or more files already exist: %s", path)
}
if err != nil && !errors.Is(err, fs.ErrNotExist) {
} else if !errors.Is(err, fs.ErrNotExist) {
return fmt.Errorf("error while verifying file %s does not already exist: %w", path, err)
}
}