-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
298 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
/swagger_go.json | ||
/.env | ||
plan.out | ||
*.out | ||
|
||
*.dll | ||
*.exe | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,21 @@ | ||
package provider | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-testing/terraform" | ||
) | ||
|
||
func TestAccDataDnsZone(t *testing.T) { | ||
accTest(t, []resource.TestStep{ | ||
{ | ||
Config: `data "netlify_dns_zone" "example" { | ||
name = "examplepetstore.com" | ||
}`, | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("data.netlify_dns_zone.example", "id", "66afdbce3cf2b4f0fab520d9"), | ||
), | ||
}, | ||
}, func(s *terraform.State) error { return nil }) | ||
} |
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
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,58 @@ | ||
package provider | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-testing/plancheck" | ||
"github.com/hashicorp/terraform-plugin-testing/terraform" | ||
) | ||
|
||
func TestAccDnsZone(t *testing.T) { | ||
accTest(t, []resource.TestStep{ | ||
{ | ||
Config: `resource "netlify_dns_zone" "example" { | ||
name = "tfsoftsecretnetlifytestingexamplestore.com" | ||
team_slug = "netlify-terraform-test" | ||
}`, | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttrSet("netlify_dns_zone.example", "id"), | ||
resource.TestCheckResourceAttr("netlify_dns_zone.example", "team_id", "66ae34e11a567e9092e3850f"), | ||
), | ||
}, | ||
{ | ||
ResourceName: "netlify_dns_zone.example", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"last_updated"}, | ||
}, | ||
|
||
{ | ||
Config: `resource "netlify_dns_zone" "example" { | ||
name = "tfsoftsecretnetlifytestingexamplestore2.com" | ||
team_slug = "netlify-terraform-test" | ||
}`, | ||
ConfigPlanChecks: resource.ConfigPlanChecks{ | ||
PreApply: []plancheck.PlanCheck{ | ||
plancheck.ExpectResourceAction("netlify_dns_zone.example", plancheck.ResourceActionReplace), | ||
}, | ||
}, | ||
}, | ||
}, testAccDnsZoneDestroy) | ||
} | ||
|
||
func testAccDnsZoneDestroy(s *terraform.State) error { | ||
for _, m := range s.Modules { | ||
if v, ok := m.Resources["netlify_dns_zone.example"]; ok { | ||
key, _, err := testAccProvider.client.DNSZonesAPI.GetDnsZone(context.Background(), v.Primary.Attributes["id"]).Execute() | ||
if err != nil { | ||
//lint:ignore nilerr we expect an error to know it was not found | ||
return nil | ||
} | ||
return fmt.Errorf("DNS zone still exists: %s", key.Id) | ||
} | ||
} | ||
return fmt.Errorf("not found in testAccDnsZoneDestroy check destroy") | ||
} |
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,85 @@ | ||
package provider | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-testing/plancheck" | ||
"github.com/hashicorp/terraform-plugin-testing/terraform" | ||
) | ||
|
||
func TestAccLogDrain(t *testing.T) { | ||
var siteId = "5b407d6d-9385-4e7a-a4c4-8efc11ea3c26" | ||
accTest(t, []resource.TestStep{ | ||
{ | ||
Config: fmt.Sprintf(`resource "netlify_log_drain" "example" { | ||
site_id = "%s" | ||
destination = "http" | ||
log_types = ["deploys"] | ||
format = "ndjson" | ||
exclude_pii = false | ||
service_config = { | ||
url = "https://httpstat.us/200" | ||
} | ||
}`, siteId), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttrSet("netlify_log_drain.example", "id"), | ||
resource.TestCheckResourceAttr("netlify_log_drain.example", "site_id", siteId), | ||
resource.TestCheckResourceAttr("netlify_log_drain.example", "destination", "http"), | ||
resource.TestCheckResourceAttr("netlify_log_drain.example", "exclude_pii", "false"), | ||
), | ||
}, | ||
{ | ||
ResourceName: "netlify_log_drain.example", | ||
ImportState: true, | ||
ImportStateIdFunc: func(s *terraform.State) (string, error) { | ||
for _, m := range s.Modules { | ||
if v, ok := m.Resources["netlify_log_drain.example"]; ok { | ||
return fmt.Sprintf("%s:%s", v.Primary.Attributes["site_id"], v.Primary.Attributes["id"]), nil | ||
} | ||
} | ||
return "", fmt.Errorf("not found in TestAccLogDrain import test step") | ||
}, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"last_updated"}, | ||
}, | ||
|
||
{ | ||
Config: fmt.Sprintf(`resource "netlify_log_drain" "example" { | ||
site_id = "%s" | ||
destination = "http" | ||
log_types = ["deploys"] | ||
format = "ndjson" | ||
exclude_pii = true | ||
service_config = { | ||
url = "https://httpstat.us/200" | ||
} | ||
}`, siteId), | ||
ConfigPlanChecks: resource.ConfigPlanChecks{ | ||
PreApply: []plancheck.PlanCheck{ | ||
plancheck.ExpectResourceAction("netlify_log_drain.example", plancheck.ResourceActionUpdate), | ||
}, | ||
}, | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr("netlify_log_drain.example", "site_id", siteId), | ||
resource.TestCheckResourceAttr("netlify_log_drain.example", "exclude_pii", "true"), | ||
), | ||
}, | ||
}, testAccLogDrainDestroy) | ||
} | ||
|
||
func testAccLogDrainDestroy(s *terraform.State) error { | ||
for _, m := range s.Modules { | ||
if v, ok := m.Resources["netlify_log_drain.example"]; ok { | ||
key, _, err := testAccProvider.client.LogDrainsAPI.LogDrainsIndex(context.Background(), v.Primary.Attributes["site_id"]).Execute() | ||
if err != nil { | ||
//lint:ignore nilerr we expect an error to know it was not found | ||
return nil | ||
} | ||
return fmt.Errorf("Log drain still exists: %s", key.Id) | ||
} | ||
} | ||
return fmt.Errorf("not found in testAccLogDrainDestroy check destroy") | ||
} |
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,27 @@ | ||
package provider | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-testing/terraform" | ||
) | ||
|
||
func TestAccDataSite(t *testing.T) { | ||
accTest(t, []resource.TestStep{ | ||
{ | ||
Config: `data "netlify_site" "example_by_id" { | ||
id = "5b407d6d-9385-4e7a-a4c4-8efc11ea3c26" | ||
} | ||
data "netlify_site" "example_by_name" { | ||
team_slug = "netlify-terraform-test" | ||
name = "tf-test-1" | ||
}`, | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("data.netlify_site.example_by_id", "name", "tf-test-1"), | ||
resource.TestCheckResourceAttr("data.netlify_site.example_by_name", "id", "5b407d6d-9385-4e7a-a4c4-8efc11ea3c26"), | ||
), | ||
}, | ||
}, func(s *terraform.State) error { return nil }) | ||
} |
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,35 @@ | ||
package provider | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-testing/terraform" | ||
) | ||
|
||
func TestAccDataSites(t *testing.T) { | ||
accTest(t, []resource.TestStep{ | ||
{ | ||
Config: `data "netlify_sites" "example" { | ||
team_slug = "netlify-terraform-test" | ||
}`, | ||
Check: resource.ComposeTestCheckFunc( | ||
func(s *terraform.State) error { | ||
for _, m := range s.Modules { | ||
if v, ok := m.Resources["data.netlify_sites.example"]; ok { | ||
for k, v := range v.Primary.Attributes { | ||
if strings.HasPrefix(k, "sites.") && strings.HasSuffix(k, ".name") && v == "tf-test-1" { | ||
return nil | ||
} | ||
} | ||
return fmt.Errorf("not found in sites list at TestAccDataSites test step") | ||
} | ||
} | ||
return fmt.Errorf("sites list not found in TestAccDataSites test step") | ||
}, | ||
), | ||
}, | ||
}, func(s *terraform.State) error { return nil }) | ||
} |
Oops, something went wrong.