2024-09-04 11:11:47 +00:00
|
|
|
package phases
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
terraformlib "github.com/databricks/cli/libs/terraform"
|
|
|
|
tfjson "github.com/hashicorp/terraform-json"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestParseTerraformActions(t *testing.T) {
|
|
|
|
changes := []*tfjson.ResourceChange{
|
|
|
|
{
|
|
|
|
Type: "databricks_pipeline",
|
|
|
|
Change: &tfjson.Change{
|
|
|
|
Actions: tfjson.Actions{tfjson.ActionCreate},
|
|
|
|
},
|
|
|
|
Name: "create pipeline",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: "databricks_pipeline",
|
|
|
|
Change: &tfjson.Change{
|
|
|
|
Actions: tfjson.Actions{tfjson.ActionDelete},
|
|
|
|
},
|
|
|
|
Name: "delete pipeline",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: "databricks_pipeline",
|
|
|
|
Change: &tfjson.Change{
|
|
|
|
Actions: tfjson.Actions{tfjson.ActionDelete, tfjson.ActionCreate},
|
|
|
|
},
|
|
|
|
Name: "recreate pipeline",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: "databricks_whatever",
|
|
|
|
Change: &tfjson.Change{
|
|
|
|
Actions: tfjson.Actions{tfjson.ActionDelete, tfjson.ActionCreate},
|
|
|
|
},
|
|
|
|
Name: "recreate whatever",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-12-02 21:18:07 +00:00
|
|
|
res := filterDeleteOrRecreateActions(changes, "databricks_pipeline")
|
2024-09-04 11:11:47 +00:00
|
|
|
|
|
|
|
assert.Equal(t, []terraformlib.Action{
|
|
|
|
{
|
|
|
|
Action: terraformlib.ActionTypeDelete,
|
|
|
|
ResourceType: "databricks_pipeline",
|
|
|
|
ResourceName: "delete pipeline",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Action: terraformlib.ActionTypeRecreate,
|
|
|
|
ResourceType: "databricks_pipeline",
|
|
|
|
ResourceName: "recreate pipeline",
|
|
|
|
},
|
|
|
|
}, res)
|
|
|
|
}
|