2023-04-17 10:21:21 +00:00
|
|
|
package config_tests
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
2023-05-16 16:35:39 +00:00
|
|
|
"github.com/databricks/cli/bundle"
|
|
|
|
"github.com/databricks/cli/bundle/config/mutator"
|
2023-04-17 10:21:21 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestConflictingResourceIdsNoSubconfig(t *testing.T) {
|
|
|
|
_, err := bundle.Load("./conflicting_resource_ids/no_subconfigurations")
|
2023-07-18 10:16:34 +00:00
|
|
|
bundleConfigPath := filepath.FromSlash("conflicting_resource_ids/no_subconfigurations/databricks.yml")
|
2023-04-17 10:21:21 +00:00
|
|
|
assert.ErrorContains(t, err, fmt.Sprintf("multiple resources named foo (job at %s, pipeline at %s)", bundleConfigPath, bundleConfigPath))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestConflictingResourceIdsOneSubconfig(t *testing.T) {
|
|
|
|
b, err := bundle.Load("./conflicting_resource_ids/one_subconfiguration")
|
|
|
|
require.NoError(t, err)
|
2023-05-24 12:45:19 +00:00
|
|
|
err = bundle.Apply(context.Background(), b, bundle.Seq(mutator.DefaultMutators()...))
|
2023-07-18 10:16:34 +00:00
|
|
|
bundleConfigPath := filepath.FromSlash("conflicting_resource_ids/one_subconfiguration/databricks.yml")
|
2023-04-17 10:21:21 +00:00
|
|
|
resourcesConfigPath := filepath.FromSlash("conflicting_resource_ids/one_subconfiguration/resources.yml")
|
|
|
|
assert.ErrorContains(t, err, fmt.Sprintf("multiple resources named foo (job at %s, pipeline at %s)", bundleConfigPath, resourcesConfigPath))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestConflictingResourceIdsTwoSubconfigs(t *testing.T) {
|
|
|
|
b, err := bundle.Load("./conflicting_resource_ids/two_subconfigurations")
|
|
|
|
require.NoError(t, err)
|
2023-05-24 12:45:19 +00:00
|
|
|
err = bundle.Apply(context.Background(), b, bundle.Seq(mutator.DefaultMutators()...))
|
2023-04-17 10:21:21 +00:00
|
|
|
resources1ConfigPath := filepath.FromSlash("conflicting_resource_ids/two_subconfigurations/resources1.yml")
|
|
|
|
resources2ConfigPath := filepath.FromSlash("conflicting_resource_ids/two_subconfigurations/resources2.yml")
|
|
|
|
assert.ErrorContains(t, err, fmt.Sprintf("multiple resources named foo (job at %s, pipeline at %s)", resources1ConfigPath, resources2ConfigPath))
|
|
|
|
}
|