From 22c7110e17a6c3c9e799bf674b24a1d7c3b6eaf5 Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Wed, 4 Dec 2024 20:48:48 +0100 Subject: [PATCH] Extend empty_bundle_test.go to check if remote path is created prematurely --- internal/bundle/empty_bundle_test.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/internal/bundle/empty_bundle_test.go b/internal/bundle/empty_bundle_test.go index 36883ae001..e6d3f97418 100644 --- a/internal/bundle/empty_bundle_test.go +++ b/internal/bundle/empty_bundle_test.go @@ -8,11 +8,17 @@ 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() @@ -20,11 +26,20 @@ func TestAccEmptyBundleDeploy(t *testing.T) { 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) @@ -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) + }