github.com/databricks/cli@v0.203.0/bundle/tests/conflicting_resource_ids_test.go (about)

     1  package config_tests
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  	"path/filepath"
     7  	"testing"
     8  
     9  	"github.com/databricks/cli/bundle"
    10  	"github.com/databricks/cli/bundle/config/mutator"
    11  	"github.com/stretchr/testify/assert"
    12  	"github.com/stretchr/testify/require"
    13  )
    14  
    15  func TestConflictingResourceIdsNoSubconfig(t *testing.T) {
    16  	_, err := bundle.Load("./conflicting_resource_ids/no_subconfigurations")
    17  	bundleConfigPath := filepath.FromSlash("conflicting_resource_ids/no_subconfigurations/databricks.yml")
    18  	assert.ErrorContains(t, err, fmt.Sprintf("multiple resources named foo (job at %s, pipeline at %s)", bundleConfigPath, bundleConfigPath))
    19  }
    20  
    21  func TestConflictingResourceIdsOneSubconfig(t *testing.T) {
    22  	b, err := bundle.Load("./conflicting_resource_ids/one_subconfiguration")
    23  	require.NoError(t, err)
    24  	err = bundle.Apply(context.Background(), b, bundle.Seq(mutator.DefaultMutators()...))
    25  	bundleConfigPath := filepath.FromSlash("conflicting_resource_ids/one_subconfiguration/databricks.yml")
    26  	resourcesConfigPath := filepath.FromSlash("conflicting_resource_ids/one_subconfiguration/resources.yml")
    27  	assert.ErrorContains(t, err, fmt.Sprintf("multiple resources named foo (job at %s, pipeline at %s)", bundleConfigPath, resourcesConfigPath))
    28  }
    29  
    30  func TestConflictingResourceIdsTwoSubconfigs(t *testing.T) {
    31  	b, err := bundle.Load("./conflicting_resource_ids/two_subconfigurations")
    32  	require.NoError(t, err)
    33  	err = bundle.Apply(context.Background(), b, bundle.Seq(mutator.DefaultMutators()...))
    34  	resources1ConfigPath := filepath.FromSlash("conflicting_resource_ids/two_subconfigurations/resources1.yml")
    35  	resources2ConfigPath := filepath.FromSlash("conflicting_resource_ids/two_subconfigurations/resources2.yml")
    36  	assert.ErrorContains(t, err, fmt.Sprintf("multiple resources named foo (job at %s, pipeline at %s)", resources1ConfigPath, resources2ConfigPath))
    37  }