From f9287e01015719c5fd8b6d17794bbb099ff9b474 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Thu, 31 Oct 2024 17:52:45 +0100 Subject: [PATCH] address comments --- bundle/artifacts/expand_globs_test.go | 2 +- bundle/{internal => }/bundletest/location.go | 0 bundle/{internal => }/bundletest/mutate.go | 0 .../configure_dashboard_defaults_test.go | 2 +- .../expand_pipeline_glob_paths_test.go | 2 +- .../config/mutator/rewrite_sync_paths_test.go | 2 +- bundle/config/mutator/sync_infer_root_test.go | 2 +- bundle/config/mutator/translate_paths_test.go | 2 +- bundle/deploy/metadata/compute_test.go | 2 +- .../libraries/expand_glob_references_test.go | 2 +- bundle/libraries/filer_volume_test.go | 2 +- internal/bundle/artifacts_test.go | 22 +++++++++---------- 12 files changed, 20 insertions(+), 20 deletions(-) rename bundle/{internal => }/bundletest/location.go (100%) rename bundle/{internal => }/bundletest/mutate.go (100%) diff --git a/bundle/artifacts/expand_globs_test.go b/bundle/artifacts/expand_globs_test.go index dc7c77de..af048f8e 100644 --- a/bundle/artifacts/expand_globs_test.go +++ b/bundle/artifacts/expand_globs_test.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/databricks/cli/bundle" + "github.com/databricks/cli/bundle/bundletest" "github.com/databricks/cli/bundle/config" - "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/internal/testutil" "github.com/databricks/cli/libs/dyn" "github.com/stretchr/testify/assert" diff --git a/bundle/internal/bundletest/location.go b/bundle/bundletest/location.go similarity index 100% rename from bundle/internal/bundletest/location.go rename to bundle/bundletest/location.go diff --git a/bundle/internal/bundletest/mutate.go b/bundle/bundletest/mutate.go similarity index 100% rename from bundle/internal/bundletest/mutate.go rename to bundle/bundletest/mutate.go diff --git a/bundle/config/mutator/configure_dashboard_defaults_test.go b/bundle/config/mutator/configure_dashboard_defaults_test.go index 4804b715..d34c35bc 100644 --- a/bundle/config/mutator/configure_dashboard_defaults_test.go +++ b/bundle/config/mutator/configure_dashboard_defaults_test.go @@ -5,10 +5,10 @@ import ( "testing" "github.com/databricks/cli/bundle" + "github.com/databricks/cli/bundle/bundletest" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/mutator" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/dyn" "github.com/databricks/databricks-sdk-go/service/dashboards" "github.com/stretchr/testify/assert" diff --git a/bundle/config/mutator/expand_pipeline_glob_paths_test.go b/bundle/config/mutator/expand_pipeline_glob_paths_test.go index 9f70b74a..063c76b3 100644 --- a/bundle/config/mutator/expand_pipeline_glob_paths_test.go +++ b/bundle/config/mutator/expand_pipeline_glob_paths_test.go @@ -7,9 +7,9 @@ import ( "testing" "github.com/databricks/cli/bundle" + "github.com/databricks/cli/bundle/bundletest" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/dyn" "github.com/databricks/databricks-sdk-go/service/compute" "github.com/databricks/databricks-sdk-go/service/pipelines" diff --git a/bundle/config/mutator/rewrite_sync_paths_test.go b/bundle/config/mutator/rewrite_sync_paths_test.go index 0e4dfc4c..90da8792 100644 --- a/bundle/config/mutator/rewrite_sync_paths_test.go +++ b/bundle/config/mutator/rewrite_sync_paths_test.go @@ -6,9 +6,9 @@ import ( "testing" "github.com/databricks/cli/bundle" + "github.com/databricks/cli/bundle/bundletest" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/mutator" - "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/dyn" "github.com/stretchr/testify/assert" ) diff --git a/bundle/config/mutator/sync_infer_root_test.go b/bundle/config/mutator/sync_infer_root_test.go index f507cbc7..98c9d362 100644 --- a/bundle/config/mutator/sync_infer_root_test.go +++ b/bundle/config/mutator/sync_infer_root_test.go @@ -6,9 +6,9 @@ import ( "testing" "github.com/databricks/cli/bundle" + "github.com/databricks/cli/bundle/bundletest" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/mutator" - "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/dyn" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/bundle/config/mutator/translate_paths_test.go b/bundle/config/mutator/translate_paths_test.go index 9d655b27..04325b68 100644 --- a/bundle/config/mutator/translate_paths_test.go +++ b/bundle/config/mutator/translate_paths_test.go @@ -8,11 +8,11 @@ import ( "testing" "github.com/databricks/cli/bundle" + "github.com/databricks/cli/bundle/bundletest" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/mutator" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/config/variable" - "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/vfs" diff --git a/bundle/deploy/metadata/compute_test.go b/bundle/deploy/metadata/compute_test.go index 2c2c7237..2d852bf7 100644 --- a/bundle/deploy/metadata/compute_test.go +++ b/bundle/deploy/metadata/compute_test.go @@ -5,9 +5,9 @@ import ( "testing" "github.com/databricks/cli/bundle" + "github.com/databricks/cli/bundle/bundletest" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/bundle/metadata" "github.com/databricks/cli/libs/dyn" "github.com/databricks/databricks-sdk-go/service/jobs" diff --git a/bundle/libraries/expand_glob_references_test.go b/bundle/libraries/expand_glob_references_test.go index 2dfbddb7..bdd04216 100644 --- a/bundle/libraries/expand_glob_references_test.go +++ b/bundle/libraries/expand_glob_references_test.go @@ -6,9 +6,9 @@ import ( "testing" "github.com/databricks/cli/bundle" + "github.com/databricks/cli/bundle/bundletest" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/internal/testutil" "github.com/databricks/cli/libs/dyn" "github.com/databricks/databricks-sdk-go/service/compute" diff --git a/bundle/libraries/filer_volume_test.go b/bundle/libraries/filer_volume_test.go index 047a009a..987c57cb 100644 --- a/bundle/libraries/filer_volume_test.go +++ b/bundle/libraries/filer_volume_test.go @@ -7,9 +7,9 @@ import ( "testing" "github.com/databricks/cli/bundle" + "github.com/databricks/cli/bundle/bundletest" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/filer" diff --git a/internal/bundle/artifacts_test.go b/internal/bundle/artifacts_test.go index d2938fa7..3cc731f4 100644 --- a/internal/bundle/artifacts_test.go +++ b/internal/bundle/artifacts_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/databricks/cli/bundle" + "github.com/databricks/cli/bundle/bundletest" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/libraries" @@ -244,6 +245,11 @@ func TestAccUploadArtifactFileToInvalidVolume(t *testing.T) { }) require.NoError(t, err) + t.Cleanup(func() { + err = w.Schemas.DeleteByFullName(ctx, "main."+schemaName) + require.NoError(t, err) + }) + t.Run("volume not in DAB", func(t *testing.T) { volumePath := fmt.Sprintf("/Volumes/main/%s/doesnotexist", schemaName) dir := t.TempDir() @@ -307,17 +313,11 @@ func TestAccUploadArtifactFileToInvalidVolume(t *testing.T) { } // set location of volume definition in config. - b.Config.Mutate(func(v dyn.Value) (dyn.Value, error) { - return dyn.Map(v, "resources.volumes.foo", func(p dyn.Path, volume dyn.Value) (dyn.Value, error) { - return volume.WithLocations([]dyn.Location{ - { - File: filepath.Join(dir, "databricks.yml"), - Line: 1, - Column: 2, - }, - }), nil - }) - }) + bundletest.SetLocation(b, "resources.volumes.foo", []dyn.Location{{ + File: filepath.Join(dir, "databricks.yml"), + Line: 1, + Column: 2, + }}) diags := bundle.Apply(ctx, b, bundle.Seq(libraries.ExpandGlobReferences(), libraries.Upload())) assert.Contains(t, diags, diag.Diagnostic{