mirror of https://github.com/databricks/cli.git
added and fixed tests
This commit is contained in:
parent
be92aa639c
commit
27a1c7cbe4
|
@ -6,6 +6,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/databricks/cli/bundle/config/variable"
|
||||
"github.com/databricks/cli/libs/dyn"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -32,7 +33,7 @@ func TestRootLoad(t *testing.T) {
|
|||
|
||||
func TestDuplicateIdOnLoadReturnsErrorForJobAndPipeline(t *testing.T) {
|
||||
_, diags := Load("./testdata/duplicate_resource_names_in_root_job_and_pipeline/databricks.yml")
|
||||
assert.ErrorContains(t, diags.Error(), "multiple resources named foo (job at ./testdata/duplicate_resource_names_in_root_job_and_pipeline/databricks.yml:10:7, pipeline at ./testdata/duplicate_resource_names_in_root_job_and_pipeline/databricks.yml:15:7)")
|
||||
assert.ErrorContains(t, diags.Error(), "multiple resources named foo (job at ./testdata/duplicate_resource_names_in_root_job_and_pipeline/databricks.yml:10:7, pipeline at ./testdata/duplicate_resource_names_in_root_job_and_pipeline/databricks.yml:13:7)")
|
||||
}
|
||||
|
||||
func TestDuplicateIdOnLoadReturnsErrorForJobsAndExperiments(t *testing.T) {
|
||||
|
@ -62,6 +63,24 @@ func TestDuplicateIdOnMergeReturnsErrorForJobAndJob(t *testing.T) {
|
|||
assert.ErrorContains(t, err, "multiple resources named foo (job at ./testdata/duplicate_resource_name_in_subconfiguration_job_and_job/databricks.yml:10:7, job at ./testdata/duplicate_resource_name_in_subconfiguration_job_and_job/resources.yml:4:7)")
|
||||
}
|
||||
|
||||
func TestGatherResourceIdentifiers(t *testing.T) {
|
||||
root, diags := Load("./testdata/gather_resource_identifiers/databricks.yml")
|
||||
require.NoError(t, diags.Error())
|
||||
|
||||
actual, err := root.gatherResourceIdentifiers()
|
||||
assert.NoError(t, err)
|
||||
|
||||
expected := map[string]dyn.Path{
|
||||
"foo": dyn.MustPathFromString("jobs.foo"),
|
||||
"bar": dyn.MustPathFromString("jobs.bar"),
|
||||
"zab": dyn.MustPathFromString("pipelines.zab"),
|
||||
"baz": dyn.MustPathFromString("pipelines.baz"),
|
||||
"zaz": dyn.MustPathFromString("experiments.zaz"),
|
||||
"zuz": dyn.MustPathFromString("experiments.zuz"),
|
||||
}
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestInitializeVariables(t *testing.T) {
|
||||
fooDefault := "abc"
|
||||
root := &Root{
|
||||
|
|
|
@ -8,10 +8,6 @@ resources:
|
|||
jobs:
|
||||
foo:
|
||||
name: job foo
|
||||
bar:
|
||||
name: job bar
|
||||
pipelines:
|
||||
foo:
|
||||
name: pipeline foo
|
||||
baz:
|
||||
name: pipeline baz
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
bundle:
|
||||
name: test
|
||||
|
||||
workspace:
|
||||
profile: test
|
||||
|
||||
resources:
|
||||
jobs:
|
||||
foo:
|
||||
name: job foo
|
||||
bar:
|
||||
name: job bar
|
||||
pipelines:
|
||||
zab:
|
||||
name: pipeline foo
|
||||
baz:
|
||||
name: pipeline baz
|
||||
experiments:
|
||||
zaz:
|
||||
name: experiment zaz
|
||||
zuz:
|
||||
name: experiment zuz
|
Loading…
Reference in New Issue