diff --git a/exporter/importables.go b/exporter/importables.go index 451b22904e..e49cb9388a 100644 --- a/exporter/importables.go +++ b/exporter/importables.go @@ -1175,9 +1175,9 @@ var resourcesMap map[string]importable = map[string]importable{ Name: func(ic *importContext, d *schema.ResourceData) string { name := d.Get("path").(string) if name == "" { - return d.Id() + return "repo_" + d.Id() } - return nameNormalizationRegex.ReplaceAllString(name[7:], "_") + return nameNormalizationRegex.ReplaceAllString(name[7:], "_") + "_" + d.Id() }, Search: func(ic *importContext, r *resource) error { reposAPI := repos.NewReposAPI(ic.Context, ic.Client) diff --git a/exporter/importables_test.go b/exporter/importables_test.go index 9c4ccc27aa..dfa52028cc 100644 --- a/exporter/importables_test.go +++ b/exporter/importables_test.go @@ -222,6 +222,17 @@ func TestClusterNameFromID(t *testing.T) { assert.Equal(t, "c", resourcesMap["databricks_cluster"].Name(ic, d)) } +func TestRepoName(t *testing.T) { + ic := importContextForTest() + d := repos.ResourceRepo().TestResourceData() + d.SetId("12345") + // Repo without path + assert.Equal(t, "repo_12345", resourcesMap["databricks_repo"].Name(ic, d)) + // Repo with path + d.Set("path", "/Repos/user/test") + assert.Equal(t, "user_test_12345", resourcesMap["databricks_repo"].Name(ic, d)) +} + func TestJobName(t *testing.T) { ic := importContextForTest() d := jobs.ResourceJob().TestResourceData() @@ -775,13 +786,6 @@ func TestGlobalInitScriptsBodyErrors(t *testing.T) { }) } -func TestRepoIdForName(t *testing.T) { - d := repos.ResourceRepo().TestResourceData() - d.SetId("x") - ic := importContextForTest() - assert.Equal(t, "x", resourcesMap["databricks_repo"].Name(ic, d)) -} - func TestRepoListFails(t *testing.T) { qa.HTTPFixturesApply(t, []qa.HTTPFixture{ {