Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnester committed Jun 19, 2024
1 parent d8f50f2 commit f7eba5f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
11 changes: 2 additions & 9 deletions bundle/config/mutator/resolve_resource_references_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,22 +194,15 @@ func TestResolveLookupVariableReferencesInVariableLookups(t *testing.T) {
}

func TestNoResolveLookupIfVariableSetWithEnvVariable(t *testing.T) {
s := func(s string) *string {
return &s
}

b := &bundle.Bundle{
Config: config.Root{
Bundle: config.Bundle{
Target: "dev",
},
Variables: map[string]*variable.Variable{
"foo": {
Value: s("bar"),
},
"lookup": {
Lookup: &variable.Lookup{
Cluster: "cluster-${var.foo}-${bundle.target}",
Cluster: "cluster-${bundle.target}",
},
},
},
Expand All @@ -224,5 +217,5 @@ func TestNoResolveLookupIfVariableSetWithEnvVariable(t *testing.T) {

diags := bundle.Apply(ctx, b, bundle.Seq(SetVariables(), ResolveVariableReferencesInLookup(), ResolveResourceReferences()))
require.NoError(t, diags.Error())
require.Equal(t, "1234-5678-abcd", *b.Config.Variables["lookup"].Value)
require.Equal(t, "1234-5678-abcd", b.Config.Variables["lookup"].Value)
}
12 changes: 12 additions & 0 deletions bundle/tests/complex_variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config/mutator"
"github.com/databricks/databricks-sdk-go/service/compute"
"github.com/stretchr/testify/require"
)

Expand All @@ -24,6 +25,17 @@ func TestComplexVariables(t *testing.T) {
require.Equal(t, "13.2.x-scala2.11", b.Config.Resources.Jobs["my_job"].JobClusters[0].NewCluster.SparkVersion)
require.Equal(t, 2, b.Config.Resources.Jobs["my_job"].JobClusters[0].NewCluster.NumWorkers)
require.Equal(t, "true", b.Config.Resources.Jobs["my_job"].JobClusters[0].NewCluster.SparkConf["spark.speculation"])

require.Equal(t, 3, len(b.Config.Resources.Jobs["my_job"].Tasks[0].Libraries))
require.Contains(t, b.Config.Resources.Jobs["my_job"].Tasks[0].Libraries, compute.Library{
Jar: "/path/to/jar",
})
require.Contains(t, b.Config.Resources.Jobs["my_job"].Tasks[0].Libraries, compute.Library{
Egg: "/path/to/egg",
})
require.Contains(t, b.Config.Resources.Jobs["my_job"].Tasks[0].Libraries, compute.Library{
Whl: "/path/to/whl",
})
}

func TestComplexVariablesOverride(t *testing.T) {
Expand Down
9 changes: 9 additions & 0 deletions bundle/tests/variables/complex/databricks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ resources:
tasks:
- task_key: test
job_cluster_key: key
libraries: ${var.libraries}

variables:
cluster:
Expand All @@ -22,6 +23,14 @@ variables:
spark_conf:
spark.speculation: true
spark.databricks.delta.retentionDurationCheck.enabled: false
libraries:
type: complex
description: "A libraries definition"
default:
- jar: "/path/to/jar"
- egg: "/path/to/egg"
- whl: "/path/to/whl"


targets:
default:
Expand Down
6 changes: 3 additions & 3 deletions bundle/tests/variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ func TestVariablesWithTargetLookupOverrides(t *testing.T) {
))

require.NoError(t, diags.Error())
assert.Equal(t, "4321", *b.Config.Variables["d"].Value)
assert.Equal(t, "1234", *b.Config.Variables["e"].Value)
assert.Equal(t, "9876", *b.Config.Variables["f"].Value)
assert.Equal(t, "4321", b.Config.Variables["d"].Value)
assert.Equal(t, "1234", b.Config.Variables["e"].Value)
assert.Equal(t, "9876", b.Config.Variables["f"].Value)
}

func TestVariableTargetOverrides(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions libs/dyn/convert/from_typed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ func TestFromTypedAny(t *testing.T) {
"foo": "foo",
"bar": 1234,
"qux": 0,
"nil": nil,
},
}

Expand All @@ -650,6 +651,7 @@ func TestFromTypedAny(t *testing.T) {
"foo": dyn.V("foo"),
"bar": dyn.V(int64(1234)),
"qux": dyn.V(int64(0)),
"nil": dyn.V(nil),
}),
}), nv)
}

0 comments on commit f7eba5f

Please sign in to comment.