Skip to content

Commit

Permalink
Add acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tobio committed Apr 2, 2024
1 parent 295d32f commit a0998f5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions internal/elasticsearch/index/component_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ func TestAccResourceComponentTemplate(t *testing.T) {
CheckDestroy: checkResourceComponentTemplateDestroy,
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccResourceComponentTemplateEmptyTemplate(templateName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("elasticstack_elasticsearch_component_template.test", "name", templateName),
),
},
{
Config: testAccResourceComponentTemplateCreate(templateName),
Check: resource.ComposeTestCheckFunc(
Expand Down Expand Up @@ -53,6 +59,19 @@ resource "elasticstack_elasticsearch_component_template" "test" {
}`, name)
}

func testAccResourceComponentTemplateEmptyTemplate(name string) string {
return fmt.Sprintf(`
provider "elasticstack" {
elasticsearch {}
}
resource "elasticstack_elasticsearch_component_template" "test" {
name = "%s"
template {}
}`, name)
}

func checkResourceComponentTemplateDestroy(s *terraform.State) error {
client, err := clients.NewAcceptanceTestingClient()
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/elasticsearch/index/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ resource "elasticstack_elasticsearch_index_template" "test2" {
data_stream {
hidden = false
}
template {}
}
`, name, name, name)
}
Expand Down

0 comments on commit a0998f5

Please sign in to comment.