mirror of https://github.com/databricks/cli.git
Added tests
This commit is contained in:
parent
8da8dd579d
commit
f8d3c1d50c
|
@ -0,0 +1,62 @@
|
|||
package terraform
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
tfjson "github.com/hashicorp/terraform-json"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestResourceChangeEventForCreateJob(t *testing.T) {
|
||||
tfChange := tfjson.ResourceChange{
|
||||
Change: &tfjson.Change{
|
||||
Actions: []tfjson.Action{"create"},
|
||||
},
|
||||
Type: "databricks_job",
|
||||
Name: "foo",
|
||||
}
|
||||
bundleChange := toResourceChangeEvent(&tfChange)
|
||||
|
||||
assert.Equal(t, "create", string(bundleChange.Action))
|
||||
assert.Equal(t, "job", string(bundleChange.ResourceType))
|
||||
assert.Equal(t, "foo", string(bundleChange.Name))
|
||||
}
|
||||
|
||||
func TestResourceChangeEventForReplacePipeline(t *testing.T) {
|
||||
tfChange := tfjson.ResourceChange{
|
||||
Change: &tfjson.Change{
|
||||
Actions: []tfjson.Action{"delete", "create"},
|
||||
},
|
||||
Type: "databricks_pipeline",
|
||||
Name: "bar",
|
||||
}
|
||||
bundleChange := toResourceChangeEvent(&tfChange)
|
||||
|
||||
assert.Equal(t, "replace", string(bundleChange.Action))
|
||||
assert.Equal(t, "pipeline", string(bundleChange.ResourceType))
|
||||
assert.Equal(t, "bar", string(bundleChange.Name))
|
||||
}
|
||||
|
||||
func TesResourceChangeEventForDeleteExperiment(t *testing.T) {
|
||||
tfChange := tfjson.ResourceChange{
|
||||
Change: &tfjson.Change{
|
||||
Actions: []tfjson.Action{"delete"},
|
||||
},
|
||||
Type: "databricks_mlflow_experiment",
|
||||
Name: "my_exp",
|
||||
}
|
||||
bundleChange := toResourceChangeEvent(&tfChange)
|
||||
|
||||
assert.Equal(t, "delete", string(bundleChange.Action))
|
||||
assert.Equal(t, "mlflow_experiment", string(bundleChange.ResourceType))
|
||||
assert.Equal(t, "my_exp", string(bundleChange.Name))
|
||||
}
|
||||
|
||||
func TestResourceChangeEventToString(t *testing.T) {
|
||||
event := ResourceChangeEvent{
|
||||
Name: "foo",
|
||||
ResourceType: "job",
|
||||
Action: ActionCreate,
|
||||
}
|
||||
assert.Equal(t, " create job foo", event.String())
|
||||
}
|
Loading…
Reference in New Issue