Skip to content

Commit

Permalink
Update remaining call sites
Browse files Browse the repository at this point in the history
  • Loading branch information
pietern committed Dec 12, 2024
1 parent 57b156d commit e090c92
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
24 changes: 12 additions & 12 deletions bundle/tests/suggest_target_test.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package config_tests

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

"github.com/databricks/cli/cmd/root"
assert "github.com/databricks/cli/libs/dyn/dynassert"

"github.com/databricks/cli/internal"
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config/mutator"
"github.com/stretchr/testify/require"
)

func TestSuggestTargetIfWrongPassed(t *testing.T) {
t.Setenv("BUNDLE_ROOT", filepath.Join("target_overrides", "workspace"))
stdoutBytes, _, err := internal.RequireErrorRun(t, "bundle", "validate", "-e", "incorrect")
stdout := stdoutBytes.String()
b := load(t, "target_overrides/workspace")

assert.Error(t, root.ErrAlreadyPrinted, err)
assert.Contains(t, stdout, "Available targets:")
assert.Contains(t, stdout, "development")
assert.Contains(t, stdout, "staging")
ctx := context.Background()
diags := bundle.Apply(ctx, b, mutator.SelectTarget("incorrect"))
err := diags.Error()
require.Error(t, err)
require.Contains(t, err.Error(), "Available targets:")
require.Contains(t, err.Error(), "development")
require.Contains(t, err.Error(), "staging")
}
4 changes: 2 additions & 2 deletions cmd/labs/installed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"context"
"testing"

"github.com/databricks/cli/internal"
"github.com/databricks/cli/internal/testcli"
"github.com/databricks/cli/libs/env"
)

func TestListsInstalledProjects(t *testing.T) {
ctx := context.Background()
ctx = env.WithUserHomeDir(ctx, "project/testdata/installed-in-home")
r := internal.NewCobraTestRunnerWithContext(t, ctx, "labs", "installed")
r := testcli.NewRunnerWithContext(t, ctx, "labs", "installed")
r.RunAndExpectOutput(`
Name Description Version
blueprint Blueprint Project v0.3.15
Expand Down
4 changes: 2 additions & 2 deletions cmd/labs/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import (
"context"
"testing"

"github.com/databricks/cli/internal"
"github.com/databricks/cli/internal/testcli"
"github.com/databricks/cli/libs/env"
"github.com/stretchr/testify/require"
)

func TestListingWorks(t *testing.T) {
ctx := context.Background()
ctx = env.WithUserHomeDir(ctx, "project/testdata/installed-in-home")
c := internal.NewCobraTestRunnerWithContext(t, ctx, "labs", "list")
c := testcli.NewRunnerWithContext(t, ctx, "labs", "list")
stdout, _, err := c.Run()
require.NoError(t, err)
require.Contains(t, stdout.String(), "ucx")
Expand Down
10 changes: 5 additions & 5 deletions cmd/labs/project/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

"github.com/databricks/cli/internal"
"github.com/databricks/cli/internal/testcli"
"github.com/databricks/cli/libs/env"
"github.com/databricks/cli/libs/python"
"github.com/databricks/databricks-sdk-go"
Expand All @@ -30,7 +30,7 @@ func devEnvContext(t *testing.T) context.Context {

func TestRunningBlueprintEcho(t *testing.T) {
ctx := devEnvContext(t)
r := internal.NewCobraTestRunnerWithContext(t, ctx, "labs", "blueprint", "echo")
r := testcli.NewRunnerWithContext(t, ctx, "labs", "blueprint", "echo")
var out echoOut
r.RunAndParseJSON(&out)
assert.Equal(t, "echo", out.Command)
Expand All @@ -41,14 +41,14 @@ func TestRunningBlueprintEcho(t *testing.T) {

func TestRunningBlueprintEchoProfileWrongOverride(t *testing.T) {
ctx := devEnvContext(t)
r := internal.NewCobraTestRunnerWithContext(t, ctx, "labs", "blueprint", "echo", "--profile", "workspace-profile")
r := testcli.NewRunnerWithContext(t, ctx, "labs", "blueprint", "echo", "--profile", "workspace-profile")
_, _, err := r.Run()
assert.ErrorIs(t, err, databricks.ErrNotAccountClient)
}

func TestRunningCommand(t *testing.T) {
ctx := devEnvContext(t)
r := internal.NewCobraTestRunnerWithContext(t, ctx, "labs", "blueprint", "foo")
r := testcli.NewRunnerWithContext(t, ctx, "labs", "blueprint", "foo")
r.WithStdin()
defer r.CloseStdin()

Expand All @@ -60,7 +60,7 @@ func TestRunningCommand(t *testing.T) {

func TestRenderingTable(t *testing.T) {
ctx := devEnvContext(t)
r := internal.NewCobraTestRunnerWithContext(t, ctx, "labs", "blueprint", "table")
r := testcli.NewRunnerWithContext(t, ctx, "labs", "blueprint", "table")
r.RunAndExpectOutput(`
Key Value
First Second
Expand Down
8 changes: 4 additions & 4 deletions cmd/labs/project/installer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"github.com/databricks/cli/cmd/labs/github"
"github.com/databricks/cli/cmd/labs/project"
"github.com/databricks/cli/internal"
"github.com/databricks/cli/internal/testcli"
"github.com/databricks/cli/libs/env"
"github.com/databricks/cli/libs/process"
"github.com/databricks/cli/libs/python"
Expand Down Expand Up @@ -236,7 +236,7 @@ func TestInstallerWorksForReleases(t *testing.T) {
// │ │ │ └── site-packages
// │ │ │ ├── ...
// │ │ │ ├── distutils-precedence.pth
r := internal.NewCobraTestRunnerWithContext(t, ctx, "labs", "install", "blueprint", "--debug")
r := testcli.NewRunnerWithContext(t, ctx, "labs", "install", "blueprint", "--debug")
r.RunAndExpectOutput("setting up important infrastructure")
}

Expand Down Expand Up @@ -356,7 +356,7 @@ account_id = abc
// └── databrickslabs-blueprint-releases.json

// `databricks labs install .` means "verify this installer i'm developing does work"
r := internal.NewCobraTestRunnerWithContext(t, ctx, "labs", "install", ".")
r := testcli.NewRunnerWithContext(t, ctx, "labs", "install", ".")
r.WithStdin()
defer r.CloseStdin()

Expand Down Expand Up @@ -426,7 +426,7 @@ func TestUpgraderWorksForReleases(t *testing.T) {
ctx = env.Set(ctx, "DATABRICKS_CLUSTER_ID", "installer-cluster")
ctx = env.Set(ctx, "DATABRICKS_WAREHOUSE_ID", "installer-warehouse")

r := internal.NewCobraTestRunnerWithContext(t, ctx, "labs", "upgrade", "blueprint")
r := testcli.NewRunnerWithContext(t, ctx, "labs", "upgrade", "blueprint")
r.RunAndExpectOutput("setting up important infrastructure")

// Check if the stub was called with the 'python -m pip install' command
Expand Down

0 comments on commit e090c92

Please sign in to comment.