fixed test

This commit is contained in:
Andrew Nester 2024-11-21 17:46:04 +01:00
parent f135ecc799
commit cfcb787fbc
No known key found for this signature in database
GPG Key ID: 12BC628A44B7DA57
4 changed files with 21 additions and 1 deletions

View File

@ -37,6 +37,8 @@ func Initialize() bundle.Mutator {
mutator.MergeJobParameters(), mutator.MergeJobParameters(),
mutator.MergeJobTasks(), mutator.MergeJobTasks(),
mutator.MergePipelineClusters(), mutator.MergePipelineClusters(),
mutator.MergeApps(),
mutator.InitializeWorkspaceClient(), mutator.InitializeWorkspaceClient(),
mutator.PopulateCurrentUser(), mutator.PopulateCurrentUser(),

View File

@ -14,6 +14,7 @@ variables:
env: env:
- name: SOME_ENV_VARIABLE - name: SOME_ENV_VARIABLE
value: "Some value" value: "Some value"
resources: resources:
apps: apps:
my_app: my_app:

View File

@ -1,8 +1,11 @@
package config_tests package config_tests
import ( import (
"context"
"testing" "testing"
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config/mutator"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
@ -10,6 +13,13 @@ func TestApps(t *testing.T) {
b := load(t, "./apps") b := load(t, "./apps")
assert.Equal(t, "apps", b.Config.Bundle.Name) 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"] app := b.Config.Resources.Apps["my_app"]
assert.Equal(t, "my-app", app.Name) assert.Equal(t, "my-app", app.Name)
assert.Equal(t, "My App", app.Description) assert.Equal(t, "My App", app.Description)
@ -27,6 +37,12 @@ func TestAppsOverride(t *testing.T) {
b := loadTarget(t, "./apps", "development") b := loadTarget(t, "./apps", "development")
assert.Equal(t, "apps", b.Config.Bundle.Name) 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"] app := b.Config.Resources.Apps["my_app"]
assert.Equal(t, "my-app", app.Name) assert.Equal(t, "my-app", app.Name)
assert.Equal(t, "My App", app.Description) 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, "CAN_MANAGE", string(app.Resources[1].Job.Permission))
assert.Equal(t, "key", app.Resources[2].Secret.Key) assert.Equal(t, "key", app.Resources[2].Secret.Key)
assert.Equal(t, "scope", app.Resources[2].Secret.Scope) 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))
} }

View File

@ -46,6 +46,7 @@ func loadTargetWithDiags(path, env string) (*bundle.Bundle, diag.Diagnostics) {
mutator.MergeJobParameters(), mutator.MergeJobParameters(),
mutator.MergeJobTasks(), mutator.MergeJobTasks(),
mutator.MergePipelineClusters(), mutator.MergePipelineClusters(),
mutator.MergeApps(),
)) ))
return b, diags return b, diags
} }