-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Internal] Move volumes test next to plugin framework data source (#3995
) ## Changes <!-- Summary of your changes that are easy to understand --> - Moving the test file to be next to the data source definition ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [x] `make test` run locally - [x] relevant change in `docs/` folder - [x] covered with integration tests in `internal/acceptance` - [x] relevant acceptance tests are passing - [x] using Go SDK
- Loading branch information
1 parent
bb871e1
commit 0cb0c8a
Showing
2 changed files
with
59 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
internal/providers/pluginfw/resources/volume/data_volumes_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package volume_test | ||
|
||
import ( | ||
"strconv" | ||
"testing" | ||
|
||
"github.com/databricks/terraform-provider-databricks/internal/acceptance" | ||
"github.com/hashicorp/terraform-plugin-testing/terraform" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func checkDataSourceVolumesPluginFrameworkPopulated(t *testing.T) func(s *terraform.State) error { | ||
return func(s *terraform.State) error { | ||
_, ok := s.Modules[0].Resources["data.databricks_volumes_pluginframework.this"] | ||
require.True(t, ok, "data.databricks_volumes_pluginframework.this has to be there") | ||
num_volumes, _ := strconv.Atoi(s.Modules[0].Outputs["volumes"].Value.(string)) | ||
assert.GreaterOrEqual(t, num_volumes, 1) | ||
return nil | ||
} | ||
} | ||
|
||
func TestUcAccDataSourceVolumesPluginFramework(t *testing.T) { | ||
acceptance.UnityWorkspaceLevel(t, acceptance.Step{ | ||
Template: ` | ||
resource "databricks_catalog" "sandbox" { | ||
name = "sandbox{var.RANDOM}" | ||
comment = "this catalog is managed by terraform" | ||
properties = { | ||
purpose = "testing" | ||
} | ||
} | ||
resource "databricks_schema" "things" { | ||
catalog_name = databricks_catalog.sandbox.id | ||
name = "things{var.RANDOM}" | ||
comment = "this database is managed by terraform" | ||
properties = { | ||
kind = "various" | ||
} | ||
} | ||
resource "databricks_volume" "this" { | ||
name = "volume_data_source_test" | ||
catalog_name = databricks_catalog.sandbox.name | ||
schema_name = databricks_schema.things.name | ||
volume_type = "MANAGED" | ||
} | ||
data "databricks_volumes_pluginframework" "this" { | ||
catalog_name = databricks_catalog.sandbox.name | ||
schema_name = databricks_schema.things.name | ||
depends_on = [ databricks_volume.this ] | ||
} | ||
output "volumes" { | ||
value = length(data.databricks_volumes_pluginframework.this.ids) | ||
} | ||
`, | ||
Check: checkDataSourceVolumesPluginFrameworkPopulated(t), | ||
}) | ||
} |