diff --git a/internal/acceptance/cluster_test.go b/internal/acceptance/cluster_test.go index f399eece3f..bc1c4023d9 100644 --- a/internal/acceptance/cluster_test.go +++ b/internal/acceptance/cluster_test.go @@ -51,7 +51,7 @@ func TestAccClusterResource_CreateClusterWithLibraries(t *testing.T) { }) } -func singleNodeClusterTemplate(autoTerminationMinutes string) string { +func singleNodeClusterTemplate(autoTerminationMinutes string, isPinned bool) string { return fmt.Sprintf(` data "databricks_spark_version" "latest" { } @@ -61,6 +61,7 @@ func singleNodeClusterTemplate(autoTerminationMinutes string) string { instance_pool_id = "{env.TEST_INSTANCE_POOL_ID}" num_workers = 0 autotermination_minutes = %s + is_pinned = %t spark_conf = { "spark.databricks.cluster.profile" = "singleNode" "spark.master" = "local[*]" @@ -69,14 +70,14 @@ func singleNodeClusterTemplate(autoTerminationMinutes string) string { "ResourceClass" = "SingleNode" } } - `, autoTerminationMinutes) + `, autoTerminationMinutes, isPinned) } func TestAccClusterResource_CreateSingleNodeCluster(t *testing.T) { WorkspaceLevel(t, Step{ - Template: singleNodeClusterTemplate("10"), + Template: singleNodeClusterTemplate("10", false), }, Step{ - Template: singleNodeClusterTemplate("20"), + Template: singleNodeClusterTemplate("20", false), }) } @@ -176,6 +177,19 @@ func TestAccClusterResource_WorkloadType(t *testing.T) { }) } +func TestAccClusterResource_PinAndUnpin(t *testing.T) { + WorkspaceLevel(t, Step{ + Template: singleNodeClusterTemplate("10", false), + Check: resource.TestCheckResourceAttr("databricks_cluster.this", "is_pinned", "false"), + }, Step{ + Template: singleNodeClusterTemplate("10", true), + Check: resource.TestCheckResourceAttr("databricks_cluster.this", "is_pinned", "true"), + }, Step{ + Template: singleNodeClusterTemplate("10", false), + Check: resource.TestCheckResourceAttr("databricks_cluster.this", "is_pinned", "false"), + }) +} + func testAccClusterResourceWorkloadTypeTemplate(workloadType string) string { return fmt.Sprintf(` data "databricks_spark_version" "latest" {}