move more tests

This commit is contained in:
Shreyas Goenka 2024-05-16 16:10:55 +02:00
parent 55dcd1dc3a
commit 09975a02ef
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
10 changed files with 6 additions and 95 deletions

View File

@ -1,22 +0,0 @@
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

View File

@ -8,6 +8,7 @@ import (
"github.com/databricks/cli/bundle/deploy/metadata"
"github.com/databricks/cli/bundle/deploy/terraform"
"github.com/databricks/cli/bundle/permissions"
"github.com/databricks/cli/bundle/python"
"github.com/databricks/cli/bundle/scripts"
)
@ -42,7 +43,7 @@ func Initialize() bundle.Mutator {
mutator.DefaultQueueing(),
mutator.ExpandPipelineGlobPaths(),
mutator.TranslatePaths(),
// python.WrapperWarning(),
python.WrapperWarning(),
permissions.ApplyBundlePermissions(),
permissions.FilterCurrentUser(),
metadata.AnnotateJobs(),

View File

@ -1,13 +0,0 @@
bundle:
name: test
workspace:
profile: test
resources:
jobs:
foo:
name: job foo
pipelines:
foo:
name: pipeline foo

View File

@ -1,13 +0,0 @@
bundle:
name: test
workspace:
profile: test
include:
- "*.yml"
resources:
jobs:
foo:
name: job foo

View File

@ -1,4 +0,0 @@
resources:
pipelines:
foo:
name: pipeline foo

View File

@ -1,42 +0,0 @@
package config_tests
import (
"context"
"fmt"
"path/filepath"
"testing"
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/phases"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestConflictingResourceIdsNoSubconfig(t *testing.T) {
ctx := context.Background()
b, err := bundle.Load(ctx, "./conflicting_resource_ids/no_subconfigurations")
require.NoError(t, err)
diags := bundle.Apply(ctx, b, phases.Load())
bundleConfigPath := filepath.FromSlash("conflicting_resource_ids/no_subconfigurations/databricks.yml")
assert.ErrorContains(t, diags.Error(), fmt.Sprintf("multiple resources named foo (job at %s:10:7, pipeline at %s:13:7)", bundleConfigPath, bundleConfigPath))
}
func TestConflictingResourceIdsOneSubconfig(t *testing.T) {
ctx := context.Background()
b, err := bundle.Load(ctx, "./conflicting_resource_ids/one_subconfiguration")
require.NoError(t, err)
diags := bundle.Apply(ctx, b, phases.Load())
bundleConfigPath := filepath.FromSlash("conflicting_resource_ids/one_subconfiguration/databricks.yml")
resourcesConfigPath := filepath.FromSlash("conflicting_resource_ids/one_subconfiguration/resources.yml")
assert.ErrorContains(t, diags.Error(), fmt.Sprintf("multiple resources named foo (job at %s:13:7, pipeline at %s:4:7)", bundleConfigPath, resourcesConfigPath))
}
func TestConflictingResourceIdsTwoSubconfigs(t *testing.T) {
ctx := context.Background()
b, err := bundle.Load(ctx, "./conflicting_resource_ids/two_subconfigurations")
require.NoError(t, err)
diags := bundle.Apply(ctx, b, phases.Load())
resources1ConfigPath := filepath.FromSlash("conflicting_resource_ids/two_subconfigurations/resources1.yml")
resources2ConfigPath := filepath.FromSlash("conflicting_resource_ids/two_subconfigurations/resources2.yml")
assert.ErrorContains(t, diags.Error(), fmt.Sprintf("multiple resources named foo (job at %s:4:7, pipeline at %s:4:7)", resources1ConfigPath, resources2ConfigPath))
}

View File

@ -30,6 +30,10 @@ func TestValidateUniqueResourceIdentifiers(t *testing.T) {
// name: "duplicate_resource_name_in_subconfiguration_job_and_job",
// errorMsg: "multiple resources named foo (jobs.foo at validate/duplicate_resource_name_in_subconfiguration_job_and_job/databricks.yml:10:7, jobs.foo at validate/duplicate_resource_name_in_subconfiguration_job_and_job/resources.yml:4:7)",
// },
{
name: "duplicate_resource_names_in_different_subconfiguations",
errorMsg: "multiple resources named foo (jobs.foo at validate/duplicate_resource_names_in_different_subconfiguations/resources1.yml:4:7, pipelines.foo at validate/duplicate_resource_names_in_different_subconfiguations/resources2.yml:4:7)",
},
}
for _, tc := range tcases {