From cfcb787fbc0698df5729eb4ee2b6fcd733258067 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Thu, 21 Nov 2024 17:46:04 +0100 Subject: [PATCH] fixed test --- bundle/phases/initialize.go | 2 ++ bundle/tests/apps/databricks.yml | 1 + bundle/tests/apps_test.go | 18 +++++++++++++++++- bundle/tests/loader.go | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/bundle/phases/initialize.go b/bundle/phases/initialize.go index 3d5ad5e8..76703604 100644 --- a/bundle/phases/initialize.go +++ b/bundle/phases/initialize.go @@ -37,6 +37,8 @@ func Initialize() bundle.Mutator { mutator.MergeJobParameters(), mutator.MergeJobTasks(), mutator.MergePipelineClusters(), + mutator.MergeApps(), + mutator.InitializeWorkspaceClient(), mutator.PopulateCurrentUser(), diff --git a/bundle/tests/apps/databricks.yml b/bundle/tests/apps/databricks.yml index d2662f47..ad7e9300 100644 --- a/bundle/tests/apps/databricks.yml +++ b/bundle/tests/apps/databricks.yml @@ -14,6 +14,7 @@ variables: env: - name: SOME_ENV_VARIABLE value: "Some value" + resources: apps: my_app: diff --git a/bundle/tests/apps_test.go b/bundle/tests/apps_test.go index a606f97b..86c8eb08 100644 --- a/bundle/tests/apps_test.go +++ b/bundle/tests/apps_test.go @@ -1,8 +1,11 @@ package config_tests import ( + "context" "testing" + "github.com/databricks/cli/bundle" + "github.com/databricks/cli/bundle/config/mutator" "github.com/stretchr/testify/assert" ) @@ -10,6 +13,13 @@ func TestApps(t *testing.T) { b := load(t, "./apps") assert.Equal(t, "apps", b.Config.Bundle.Name) + diags := bundle.Apply(context.Background(), b, + bundle.Seq( + mutator.SetVariables(), + mutator.ResolveVariableReferences("variables"), + )) + assert.Empty(t, diags) + app := b.Config.Resources.Apps["my_app"] assert.Equal(t, "my-app", app.Name) assert.Equal(t, "My App", app.Description) @@ -27,6 +37,12 @@ func TestAppsOverride(t *testing.T) { b := loadTarget(t, "./apps", "development") assert.Equal(t, "apps", b.Config.Bundle.Name) + diags := bundle.Apply(context.Background(), b, + bundle.Seq( + mutator.SetVariables(), + mutator.ResolveVariableReferences("variables"), + )) + assert.Empty(t, diags) app := b.Config.Resources.Apps["my_app"] assert.Equal(t, "my-app", app.Name) assert.Equal(t, "My App", app.Description) @@ -40,6 +56,6 @@ func TestAppsOverride(t *testing.T) { assert.Equal(t, "CAN_MANAGE", string(app.Resources[1].Job.Permission)) assert.Equal(t, "key", app.Resources[2].Secret.Key) assert.Equal(t, "scope", app.Resources[2].Secret.Scope) - assert.Equal(t, "CAN_USE", string(app.Resources[2].SqlWarehouse.Permission)) + assert.Equal(t, "CAN_USE", string(app.Resources[2].Secret.Permission)) } diff --git a/bundle/tests/loader.go b/bundle/tests/loader.go index 5c48d81c..8e009db4 100644 --- a/bundle/tests/loader.go +++ b/bundle/tests/loader.go @@ -46,6 +46,7 @@ func loadTargetWithDiags(path, env string) (*bundle.Bundle, diag.Diagnostics) { mutator.MergeJobParameters(), mutator.MergeJobTasks(), mutator.MergePipelineClusters(), + mutator.MergeApps(), )) return b, diags }