Skip to content

Commit e090c92

Browse files
committed
Update remaining call sites
1 parent 57b156d commit e090c92

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
package config_tests
22

33
import (
4-
"path/filepath"
4+
"context"
55
"testing"
66

7-
"github.com/databricks/cli/cmd/root"
8-
assert "github.com/databricks/cli/libs/dyn/dynassert"
9-
10-
"github.com/databricks/cli/internal"
7+
"github.com/databricks/cli/bundle"
8+
"github.com/databricks/cli/bundle/config/mutator"
9+
"github.com/stretchr/testify/require"
1110
)
1211

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

18-
assert.Error(t, root.ErrAlreadyPrinted, err)
19-
assert.Contains(t, stdout, "Available targets:")
20-
assert.Contains(t, stdout, "development")
21-
assert.Contains(t, stdout, "staging")
15+
ctx := context.Background()
16+
diags := bundle.Apply(ctx, b, mutator.SelectTarget("incorrect"))
17+
err := diags.Error()
18+
require.Error(t, err)
19+
require.Contains(t, err.Error(), "Available targets:")
20+
require.Contains(t, err.Error(), "development")
21+
require.Contains(t, err.Error(), "staging")
2222
}

cmd/labs/installed_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import (
44
"context"
55
"testing"
66

7-
"github.com/databricks/cli/internal"
7+
"github.com/databricks/cli/internal/testcli"
88
"github.com/databricks/cli/libs/env"
99
)
1010

1111
func TestListsInstalledProjects(t *testing.T) {
1212
ctx := context.Background()
1313
ctx = env.WithUserHomeDir(ctx, "project/testdata/installed-in-home")
14-
r := internal.NewCobraTestRunnerWithContext(t, ctx, "labs", "installed")
14+
r := testcli.NewRunnerWithContext(t, ctx, "labs", "installed")
1515
r.RunAndExpectOutput(`
1616
Name Description Version
1717
blueprint Blueprint Project v0.3.15

cmd/labs/list_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import (
44
"context"
55
"testing"
66

7-
"github.com/databricks/cli/internal"
7+
"github.com/databricks/cli/internal/testcli"
88
"github.com/databricks/cli/libs/env"
99
"github.com/stretchr/testify/require"
1010
)
1111

1212
func TestListingWorks(t *testing.T) {
1313
ctx := context.Background()
1414
ctx = env.WithUserHomeDir(ctx, "project/testdata/installed-in-home")
15-
c := internal.NewCobraTestRunnerWithContext(t, ctx, "labs", "list")
15+
c := testcli.NewRunnerWithContext(t, ctx, "labs", "list")
1616
stdout, _, err := c.Run()
1717
require.NoError(t, err)
1818
require.Contains(t, stdout.String(), "ucx")

cmd/labs/project/command_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"testing"
77
"time"
88

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

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

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

4949
func TestRunningCommand(t *testing.T) {
5050
ctx := devEnvContext(t)
51-
r := internal.NewCobraTestRunnerWithContext(t, ctx, "labs", "blueprint", "foo")
51+
r := testcli.NewRunnerWithContext(t, ctx, "labs", "blueprint", "foo")
5252
r.WithStdin()
5353
defer r.CloseStdin()
5454

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

6161
func TestRenderingTable(t *testing.T) {
6262
ctx := devEnvContext(t)
63-
r := internal.NewCobraTestRunnerWithContext(t, ctx, "labs", "blueprint", "table")
63+
r := testcli.NewRunnerWithContext(t, ctx, "labs", "blueprint", "table")
6464
r.RunAndExpectOutput(`
6565
Key Value
6666
First Second

cmd/labs/project/installer_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919

2020
"github.com/databricks/cli/cmd/labs/github"
2121
"github.com/databricks/cli/cmd/labs/project"
22-
"github.com/databricks/cli/internal"
22+
"github.com/databricks/cli/internal/testcli"
2323
"github.com/databricks/cli/libs/env"
2424
"github.com/databricks/cli/libs/process"
2525
"github.com/databricks/cli/libs/python"
@@ -236,7 +236,7 @@ func TestInstallerWorksForReleases(t *testing.T) {
236236
// │ │ │ └── site-packages
237237
// │ │ │ ├── ...
238238
// │ │ │ ├── distutils-precedence.pth
239-
r := internal.NewCobraTestRunnerWithContext(t, ctx, "labs", "install", "blueprint", "--debug")
239+
r := testcli.NewRunnerWithContext(t, ctx, "labs", "install", "blueprint", "--debug")
240240
r.RunAndExpectOutput("setting up important infrastructure")
241241
}
242242

@@ -356,7 +356,7 @@ account_id = abc
356356
// └── databrickslabs-blueprint-releases.json
357357

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

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

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

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

0 commit comments

Comments
 (0)