Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cmd/sync/sync.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,6 @@ import (
"github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/libs/flags"
"github.com/databricks/cli/libs/sync"
"github.com/databricks/databricks-sdk-go"
"github.com/spf13/cobra"
)

Expand DownExpand Up@@ -70,7 +69,7 @@ func (f *syncFlags) syncOptionsFromArgs(cmd *cobra.Command, args []string) (*syn
// The sync code will automatically create this directory if it doesn't
// exist and add it to the `.gitignore` file in the root.
SnapshotBasePath: filepath.Join(args[0], ".databricks"),
WorkspaceClient: databricks.Must(databricks.NewWorkspaceClient()),
WorkspaceClient: root.WorkspaceClient(cmd.Context()),
}
return &opts, nil
}
Expand Down
6 changes: 5 additions & 1 deletion cmd/sync/sync_test.go
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
package sync

import (
"context"
"flag"
"path/filepath"
"testing"

"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config"
"github.com/databricks/cli/cmd/root"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand DownExpand Up@@ -49,7 +51,9 @@ func TestSyncOptionsFromArgsRequiredTwoArgs(t *testing.T) {

func TestSyncOptionsFromArgs(t *testing.T) {
f := syncFlags{}
opts, err := f.syncOptionsFromArgs(New(), []string{"/local", "/remote"})
cmd := New()
cmd.SetContext(root.SetWorkspaceClient(context.Background(), nil))
opts, err := f.syncOptionsFromArgs(cmd, []string{"/local", "/remote"})
require.NoError(t, err)
assert.Equal(t, "/local", opts.LocalPath)
assert.Equal(t, "/remote", opts.RemotePath)
Expand Down