Skip to content

Commit

Permalink
Extend empty_bundle_test.go to check if remote path is created premat…
Browse files Browse the repository at this point in the history
…urely
  • Loading branch information
denik committed Dec 4, 2024
1 parent 0a36681 commit 22c7110
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions internal/bundle/empty_bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,38 @@ import (

"github.com/databricks/cli/internal/acc"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestAccEmptyBundleDeploy(t *testing.T) {
ctx, _ := acc.WorkspaceTest(t)
ctx, w := acc.WorkspaceTest(t)

uniqueId := uuid.New().String()
me, err := w.W.CurrentUser.Me(ctx)
require.NoError(t, err)
remoteRoot := fmt.Sprintf("/Workspace/Users/%s/.bundle/%s", me.UserName, uniqueId)

// create empty bundle
tmpDir := t.TempDir()
f, err := os.Create(filepath.Join(tmpDir, "databricks.yml"))
require.NoError(t, err)

bundleRoot := fmt.Sprintf(`bundle:
name: %s`, uuid.New().String())
name: %s`, uniqueId)
_, err = f.WriteString(bundleRoot)
require.NoError(t, err)
f.Close()

_, err = w.W.Workspace.GetStatusByPath(ctx, remoteRoot)
assert.ErrorContains(t, err, "doesn't exist")

mustValidateBundle(t, ctx, tmpDir)

// regression: "bundle validate" must not create a directory
_, err = w.W.Workspace.GetStatusByPath(ctx, remoteRoot)
require.ErrorContains(t, err, "doesn't exist")

// deploy empty bundle
err = deployBundle(t, ctx, tmpDir)
require.NoError(t, err)
Expand All @@ -33,4 +48,9 @@ func TestAccEmptyBundleDeploy(t *testing.T) {
err = destroyBundle(t, ctx, tmpDir)
require.NoError(t, err)
})

// verify that remoteRoot was actually relevant location to test
_, err = w.W.Workspace.GetStatusByPath(ctx, remoteRoot)
assert.NoError(t, err)

}

0 comments on commit 22c7110

Please sign in to comment.