diff --git a/docs/resources/netsuite_connection.md b/docs/resources/netsuite_connection.md index e338bfa..20fddda 100644 --- a/docs/resources/netsuite_connection.md +++ b/docs/resources/netsuite_connection.md @@ -19,6 +19,8 @@ resource "polytomic_netsuite_connection" "netsuite" { account_id = "my-account-id" consumer_key = "my-consumer-key" consumer_secret = "my-consumer-secret" + token = "token" + token_secret = "token-secret" } } ``` diff --git a/examples/resources/polytomic_netsuite_connection/resource.tf b/examples/resources/polytomic_netsuite_connection/resource.tf index 4490051..ab56ac5 100644 --- a/examples/resources/polytomic_netsuite_connection/resource.tf +++ b/examples/resources/polytomic_netsuite_connection/resource.tf @@ -4,6 +4,8 @@ resource "polytomic_netsuite_connection" "netsuite" { account_id = "my-account-id" consumer_key = "my-consumer-key" consumer_secret = "my-consumer-secret" + token = "token" + token_secret = "token-secret" } } diff --git a/go.mod b/go.mod index d9244c4..703a575 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/hashicorp/terraform-plugin-log v0.8.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.25.0 github.com/mitchellh/mapstructure v1.5.0 - github.com/polytomic/polytomic-go v0.0.0-20230308205457-3e0a5ade2f59 + github.com/polytomic/polytomic-go v0.0.0-20230309195205-651581fb64dd github.com/rs/zerolog v1.29.0 github.com/spf13/cobra v1.6.1 github.com/spf13/viper v1.15.0 diff --git a/go.sum b/go.sum index ea66f20..378f6da 100644 --- a/go.sum +++ b/go.sum @@ -301,6 +301,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polytomic/polytomic-go v0.0.0-20230308205457-3e0a5ade2f59 h1:XJUlgDX6IN5eKYnDmd503lw+8tqYnbJMtqy4kMjJdw0= github.com/polytomic/polytomic-go v0.0.0-20230308205457-3e0a5ade2f59/go.mod h1:OYSOoZCtLFAW6hCf5YGWGXuoX6RgYAd49QEV7v7QLvo= +github.com/polytomic/polytomic-go v0.0.0-20230309195205-651581fb64dd h1:sWnD3+T2mq/ESqdO83difqnak53qEP3Fay9CYEGYZLw= +github.com/polytomic/polytomic-go v0.0.0-20230309195205-651581fb64dd/go.mod h1:OYSOoZCtLFAW6hCf5YGWGXuoX6RgYAd49QEV7v7QLvo= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= diff --git a/provider/gen/connections/connections.go b/provider/gen/connections/connections.go index 52322ba..d587007 100644 --- a/provider/gen/connections/connections.go +++ b/provider/gen/connections/connections.go @@ -23,9 +23,10 @@ const ( exportTemplate = "./provider/gen/connections/connections.go.tmpl" // Resources - connectionResourceTemplate = "./provider/gen/connections/resource.go.tmpl" - exampleResourceTemplate = "./provider/gen/connections/resource.tf.go.tmpl" - exampleResourceOutputPath = "./examples/resources" + connectionResourceTemplate = "./provider/gen/connections/resource.go.tmpl" + connectionResourceTestTemplate = "./provider/gen/connections/resource_test.go.tmpl" + exampleResourceTemplate = "./provider/gen/connections/resource.tf.go.tmpl" + exampleResourceOutputPath = "./examples/resources" // Datasources connectionDataSourceTemplate = "./provider/gen/connections/datasource.go.tmpl" @@ -76,6 +77,7 @@ type Connection struct { Config string `yaml:"config"` Datasource bool `yaml:"datasource"` Resource bool `yaml:"resource"` + SkipTest bool `yaml:"skip_test"` } type Attribute struct { @@ -147,6 +149,13 @@ func GenerateConnections() error { }) } + if !r.SkipTest && r.Resource { + err := writeConnectionTest(r) + if err != nil { + return err + } + } + err = writeConnectionExamples(r) if err != nil { return err @@ -308,6 +317,38 @@ func writeConnectionDataSource(r Connection) error { return err } +func writeConnectionTest(r Connection) error { + tmpl, err := template.New("resource_test.go.tmpl").ParseFiles(connectionResourceTestTemplate) + if err != nil { + return err + } + var buf bytes.Buffer + f, err := os.Create( + filepath.Join(outputPath, fmt.Sprintf("resource_%s_connection_test.go", r.Connection))) + if err != nil { + return err + } + defer f.Close() + + err = tmpl.Execute(&buf, Connection{ + Name: r.Name, + Connection: strings.Title(r.Connection), + ResourceName: r.Connection, + Attributes: r.Attributes, + }) + if err != nil { + return err + } + p, err := format.Source(buf.Bytes()) + if err != nil { + return err + } + + _, err = f.Write(p) + return err + +} + func writeExports(datasources, resources []Importable) error { tmpl, err := template.New("connections.go.tmpl").ParseFiles(exportTemplate) if err != nil { diff --git a/provider/gen/connections/connections.yaml b/provider/gen/connections/connections.yaml index b28a4b5..e1ad512 100644 --- a/provider/gen/connections/connections.yaml +++ b/provider/gen/connections/connections.yaml @@ -144,6 +144,7 @@ connections: config: polytomic.S3Configuration resource: true datasource: true + skip_test: true attributes: - name: AwsAccessKeyID type: string @@ -197,6 +198,7 @@ connections: config: polytomic.AthenaConfiguration resource: true datasource: true + skip_test: true attributes: - name: AccessKeyID type: string @@ -337,6 +339,7 @@ connections: config: polytomic.MarketoConfiguration datasource: true resource: true + skip_test: true attributes: - name: ClientID type: string @@ -396,6 +399,7 @@ connections: config: polytomic.ChargeBeeConnectionConfiguration datasource: true resource: true + skip_test: true attributes: - name: Site type: string @@ -629,6 +633,7 @@ connections: config: polytomic.NetsuiteConnectionConfiguration datasource: true resource: true + skip_test: true attributes: - name: AccountID type: string @@ -646,10 +651,12 @@ connections: - name: Token type: string required: true + example: token - name: TokenSecret type: string required: true sensitive: true + example: token-secret - connection: pipedrive name: Pipedrive type: polytomic.PipedriveConnectionType @@ -672,6 +679,7 @@ connections: config: polytomic.RedshiftConnectionConfiguration datasource: true resource: true + skip_test: true attributes: - name: Hostname type: string diff --git a/provider/gen/connections/resource_test.go.tmpl b/provider/gen/connections/resource_test.go.tmpl new file mode 100644 index 0000000..7ebef5d --- /dev/null +++ b/provider/gen/connections/resource_test.go.tmpl @@ -0,0 +1,107 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAcc{{ .Connection }}Connection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAcc{{ .Connection }}ConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAcc{{ .Connection }}ConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAcc{{ .Connection }}ConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAcc{{ .Connection }}ConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_{{ .ResourceName }}_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAcc{{ .Connection }}ConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_{{ .ResourceName }}_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_{{ .ResourceName }}_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAcc{{ .Connection }}ConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_{{ .ResourceName }}_connection" "test" { + name = "%s" + configuration = { + {{- range .Attributes }} + {{- if .Example }} + {{- if eq .Type "string" }} + {{ .AttrName }} = "{{ .Example }}" + {{- else }} + {{ .AttrName }} = {{ .Example }} + {{- end -}} + {{ end }} + {{- end }} + } +} +`, name) +} + +func testAcc{{ .Connection }}ConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_{{ .ResourceName }}_connection" "test" { + name = "%s" +} +`, name) +} + +func testAcc{{ .Connection }}ConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_{{ .ResourceName }}_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_affinity_connection_test.go b/provider/resource_affinity_connection_test.go new file mode 100644 index 0000000..d5c23c0 --- /dev/null +++ b/provider/resource_affinity_connection_test.go @@ -0,0 +1,99 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccAffinityConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccAffinityConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccAffinityConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccAffinityConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccAffinityConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_affinity_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccAffinityConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_affinity_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_affinity_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccAffinityConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_affinity_connection" "test" { + name = "%s" + configuration = { + api_key = "my-api-key" + } +} +`, name) +} + +func testAccAffinityConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_affinity_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccAffinityConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_affinity_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_airtable_connection_test.go b/provider/resource_airtable_connection_test.go new file mode 100644 index 0000000..2ddbc77 --- /dev/null +++ b/provider/resource_airtable_connection_test.go @@ -0,0 +1,99 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccAirtableConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccAirtableConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccAirtableConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccAirtableConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccAirtableConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_airtable_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccAirtableConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_airtable_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_airtable_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccAirtableConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_airtable_connection" "test" { + name = "%s" + configuration = { + api_key = "my-api-key" + } +} +`, name) +} + +func testAccAirtableConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_airtable_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccAirtableConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_airtable_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_amplitude_connection_test.go b/provider/resource_amplitude_connection_test.go new file mode 100644 index 0000000..8c1b0de --- /dev/null +++ b/provider/resource_amplitude_connection_test.go @@ -0,0 +1,100 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccAmplitudeConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccAmplitudeConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccAmplitudeConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccAmplitudeConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccAmplitudeConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_amplitude_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccAmplitudeConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_amplitude_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_amplitude_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccAmplitudeConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_amplitude_connection" "test" { + name = "%s" + configuration = { + api_key = "my-api-key" + secret_key = "my-secret-key" + } +} +`, name) +} + +func testAccAmplitudeConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_amplitude_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccAmplitudeConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_amplitude_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_ascend_connection_test.go b/provider/resource_ascend_connection_test.go new file mode 100644 index 0000000..63571c1 --- /dev/null +++ b/provider/resource_ascend_connection_test.go @@ -0,0 +1,99 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccAscendConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccAscendConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccAscendConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccAscendConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccAscendConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_ascend_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccAscendConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_ascend_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_ascend_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccAscendConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_ascend_connection" "test" { + name = "%s" + configuration = { + api_key = "my-api-key" + } +} +`, name) +} + +func testAccAscendConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_ascend_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccAscendConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_ascend_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_azureblob_connection_test.go b/provider/resource_azureblob_connection_test.go new file mode 100644 index 0000000..8e1b5f7 --- /dev/null +++ b/provider/resource_azureblob_connection_test.go @@ -0,0 +1,101 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccAzureblobConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccAzureblobConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccAzureblobConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccAzureblobConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccAzureblobConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_azureblob_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccAzureblobConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_azureblob_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_azureblob_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccAzureblobConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_azureblob_connection" "test" { + name = "%s" + configuration = { + account_name = "my-account" + access_key = "abcdefghijklmnopqrstuvwxyz0123456789==" + container_name = "my-container" + } +} +`, name) +} + +func testAccAzureblobConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_azureblob_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccAzureblobConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_azureblob_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_bigquery_connection_test.go b/provider/resource_bigquery_connection_test.go new file mode 100644 index 0000000..3334e50 --- /dev/null +++ b/provider/resource_bigquery_connection_test.go @@ -0,0 +1,101 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccBigqueryConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccBigqueryConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccBigqueryConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccBigqueryConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccBigqueryConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_bigquery_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccBigqueryConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_bigquery_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_bigquery_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccBigqueryConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_bigquery_connection" "test" { + name = "%s" + configuration = { + project_id = "my-project" + service_account = "data.account_credentials.json" + location = "us-central1" + } +} +`, name) +} + +func testAccBigqueryConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_bigquery_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccBigqueryConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_bigquery_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_cloudsql_connection_test.go b/provider/resource_cloudsql_connection_test.go new file mode 100644 index 0000000..6858ae6 --- /dev/null +++ b/provider/resource_cloudsql_connection_test.go @@ -0,0 +1,102 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccCloudsqlConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccCloudsqlConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccCloudsqlConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccCloudsqlConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccCloudsqlConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_cloudsql_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccCloudsqlConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_cloudsql_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_cloudsql_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccCloudsqlConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_cloudsql_connection" "test" { + name = "%s" + configuration = { + connection_name = "my-project:us-central1:my-instance" + database = "my-db" + username = "cloudsql" + credentials = "data.account_credentials.json" + } +} +`, name) +} + +func testAccCloudsqlConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_cloudsql_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccCloudsqlConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_cloudsql_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_cosmosdb_connection_test.go b/provider/resource_cosmosdb_connection_test.go new file mode 100644 index 0000000..5ef9cc3 --- /dev/null +++ b/provider/resource_cosmosdb_connection_test.go @@ -0,0 +1,100 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccCosmosdbConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccCosmosdbConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccCosmosdbConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccCosmosdbConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccCosmosdbConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_cosmosdb_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccCosmosdbConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_cosmosdb_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_cosmosdb_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccCosmosdbConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_cosmosdb_connection" "test" { + name = "%s" + configuration = { + uri = "https://my-account.documents.example.com:443" + key = "cosmosdb-secret-key" + } +} +`, name) +} + +func testAccCosmosdbConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_cosmosdb_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccCosmosdbConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_cosmosdb_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_customerio_connection_test.go b/provider/resource_customerio_connection_test.go new file mode 100644 index 0000000..27cadfc --- /dev/null +++ b/provider/resource_customerio_connection_test.go @@ -0,0 +1,101 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccCustomerioConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccCustomerioConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccCustomerioConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccCustomerioConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccCustomerioConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_customerio_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccCustomerioConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_customerio_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_customerio_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccCustomerioConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_customerio_connection" "test" { + name = "%s" + configuration = { + site_id = "my-site-id" + tracking_api_key = "my-tracking-api-key" + app_api_key = "my-app-api-key" + } +} +`, name) +} + +func testAccCustomerioConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_customerio_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccCustomerioConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_customerio_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_dialpad_connection_test.go b/provider/resource_dialpad_connection_test.go new file mode 100644 index 0000000..f6856c7 --- /dev/null +++ b/provider/resource_dialpad_connection_test.go @@ -0,0 +1,99 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccDialpadConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccDialpadConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccDialpadConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccDialpadConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccDialpadConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_dialpad_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccDialpadConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_dialpad_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_dialpad_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccDialpadConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_dialpad_connection" "test" { + name = "%s" + configuration = { + api_key = "my-api-key" + } +} +`, name) +} + +func testAccDialpadConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_dialpad_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccDialpadConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_dialpad_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_freshdesk_connection_test.go b/provider/resource_freshdesk_connection_test.go new file mode 100644 index 0000000..15e883b --- /dev/null +++ b/provider/resource_freshdesk_connection_test.go @@ -0,0 +1,100 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccFreshdeskConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccFreshdeskConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccFreshdeskConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccFreshdeskConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccFreshdeskConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_freshdesk_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccFreshdeskConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_freshdesk_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_freshdesk_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccFreshdeskConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_freshdesk_connection" "test" { + name = "%s" + configuration = { + apikey = "my-api-key" + subdomain = "example.freshdesk.com" + } +} +`, name) +} + +func testAccFreshdeskConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_freshdesk_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccFreshdeskConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_freshdesk_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_fullstory_connection_test.go b/provider/resource_fullstory_connection_test.go new file mode 100644 index 0000000..070df7e --- /dev/null +++ b/provider/resource_fullstory_connection_test.go @@ -0,0 +1,99 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccFullstoryConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccFullstoryConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccFullstoryConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccFullstoryConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccFullstoryConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_fullstory_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccFullstoryConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_fullstory_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_fullstory_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccFullstoryConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_fullstory_connection" "test" { + name = "%s" + configuration = { + api_key = "my-api-key" + } +} +`, name) +} + +func testAccFullstoryConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_fullstory_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccFullstoryConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_fullstory_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_gcs_connection_test.go b/provider/resource_gcs_connection_test.go new file mode 100644 index 0000000..dd86f08 --- /dev/null +++ b/provider/resource_gcs_connection_test.go @@ -0,0 +1,101 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccGcsConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccGcsConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccGcsConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccGcsConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccGcsConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_gcs_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccGcsConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_gcs_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_gcs_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccGcsConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_gcs_connection" "test" { + name = "%s" + configuration = { + project_id = "my-project" + service_account = "data.account_credentials.json" + bucket = "my-bucket" + } +} +`, name) +} + +func testAccGcsConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_gcs_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccGcsConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_gcs_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_harmonic_connection_test.go b/provider/resource_harmonic_connection_test.go new file mode 100644 index 0000000..e3f5419 --- /dev/null +++ b/provider/resource_harmonic_connection_test.go @@ -0,0 +1,99 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccHarmonicConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccHarmonicConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccHarmonicConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccHarmonicConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccHarmonicConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_harmonic_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccHarmonicConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_harmonic_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_harmonic_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccHarmonicConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_harmonic_connection" "test" { + name = "%s" + configuration = { + api_key = "my-api-key" + } +} +`, name) +} + +func testAccHarmonicConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_harmonic_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccHarmonicConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_harmonic_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_intercom_connection_test.go b/provider/resource_intercom_connection_test.go new file mode 100644 index 0000000..55001fe --- /dev/null +++ b/provider/resource_intercom_connection_test.go @@ -0,0 +1,99 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccIntercomConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccIntercomConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccIntercomConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccIntercomConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccIntercomConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_intercom_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccIntercomConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_intercom_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_intercom_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccIntercomConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_intercom_connection" "test" { + name = "%s" + configuration = { + api_key = "my-api-key" + } +} +`, name) +} + +func testAccIntercomConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_intercom_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccIntercomConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_intercom_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_klaviyo_connection_test.go b/provider/resource_klaviyo_connection_test.go new file mode 100644 index 0000000..2831979 --- /dev/null +++ b/provider/resource_klaviyo_connection_test.go @@ -0,0 +1,99 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccKlaviyoConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccKlaviyoConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccKlaviyoConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccKlaviyoConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccKlaviyoConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_klaviyo_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccKlaviyoConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_klaviyo_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_klaviyo_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccKlaviyoConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_klaviyo_connection" "test" { + name = "%s" + configuration = { + api_key = "my-api-key" + } +} +`, name) +} + +func testAccKlaviyoConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_klaviyo_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccKlaviyoConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_klaviyo_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_kustomer_connection_test.go b/provider/resource_kustomer_connection_test.go new file mode 100644 index 0000000..8208df2 --- /dev/null +++ b/provider/resource_kustomer_connection_test.go @@ -0,0 +1,100 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccKustomerConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccKustomerConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccKustomerConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccKustomerConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccKustomerConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_kustomer_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccKustomerConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_kustomer_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_kustomer_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccKustomerConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_kustomer_connection" "test" { + name = "%s" + configuration = { + apikey = "my-api-key" + domain = "my-domain.example.com" + } +} +`, name) +} + +func testAccKustomerConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_kustomer_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccKustomerConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_kustomer_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_lob_connection_test.go b/provider/resource_lob_connection_test.go new file mode 100644 index 0000000..a6f7cb1 --- /dev/null +++ b/provider/resource_lob_connection_test.go @@ -0,0 +1,99 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccLobConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccLobConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccLobConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccLobConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccLobConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_lob_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccLobConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_lob_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_lob_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccLobConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_lob_connection" "test" { + name = "%s" + configuration = { + apikey = "my-api-key" + } +} +`, name) +} + +func testAccLobConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_lob_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccLobConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_lob_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_mongodb_connection_test.go b/provider/resource_mongodb_connection_test.go new file mode 100644 index 0000000..792b913 --- /dev/null +++ b/provider/resource_mongodb_connection_test.go @@ -0,0 +1,102 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccMongodbConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccMongodbConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccMongodbConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccMongodbConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccMongodbConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_mongodb_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccMongodbConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_mongodb_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_mongodb_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccMongodbConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_mongodb_connection" "test" { + name = "%s" + configuration = { + hosts = "mongodb.example.com" + username = "user" + password = "secret" + database = "db" + } +} +`, name) +} + +func testAccMongodbConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_mongodb_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccMongodbConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_mongodb_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_mysql_connection_test.go b/provider/resource_mysql_connection_test.go new file mode 100644 index 0000000..19a702b --- /dev/null +++ b/provider/resource_mysql_connection_test.go @@ -0,0 +1,103 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccMysqlConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccMysqlConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccMysqlConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccMysqlConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccMysqlConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_mysql_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccMysqlConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_mysql_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_mysql_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccMysqlConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_mysql_connection" "test" { + name = "%s" + configuration = { + hostname = "mysql.example.com" + account = "acme" + passwd = "super-secret-password" + dbname = "db" + port = 3306 + } +} +`, name) +} + +func testAccMysqlConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_mysql_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccMysqlConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_mysql_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_pipedrive_connection_test.go b/provider/resource_pipedrive_connection_test.go new file mode 100644 index 0000000..191122c --- /dev/null +++ b/provider/resource_pipedrive_connection_test.go @@ -0,0 +1,100 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccPipedriveConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccPipedriveConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccPipedriveConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccPipedriveConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccPipedriveConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_pipedrive_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccPipedriveConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_pipedrive_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_pipedrive_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccPipedriveConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_pipedrive_connection" "test" { + name = "%s" + configuration = { + api_key = "my-api-key" + domain = "my-domain.example.com" + } +} +`, name) +} + +func testAccPipedriveConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_pipedrive_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccPipedriveConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_pipedrive_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_postgresql_connection_test.go b/provider/resource_postgresql_connection_test.go new file mode 100644 index 0000000..2e2d51c --- /dev/null +++ b/provider/resource_postgresql_connection_test.go @@ -0,0 +1,103 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccPostgresqlConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccPostgresqlConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccPostgresqlConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccPostgresqlConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccPostgresqlConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_postgresql_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccPostgresqlConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_postgresql_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_postgresql_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccPostgresqlConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_postgresql_connection" "test" { + name = "%s" + configuration = { + hostname = "acme.postgres.database.example.com" + username = "acme" + password = "1234567890" + database = "acme" + port = 5432 + } +} +`, name) +} + +func testAccPostgresqlConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_postgresql_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccPostgresqlConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_postgresql_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_segment_connection_test.go b/provider/resource_segment_connection_test.go new file mode 100644 index 0000000..402191d --- /dev/null +++ b/provider/resource_segment_connection_test.go @@ -0,0 +1,99 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccSegmentConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccSegmentConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccSegmentConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccSegmentConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccSegmentConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_segment_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccSegmentConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_segment_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_segment_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccSegmentConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_segment_connection" "test" { + name = "%s" + configuration = { + write_key = "my-write-key" + } +} +`, name) +} + +func testAccSegmentConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_segment_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccSegmentConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_segment_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_snowflake_connection_test.go b/provider/resource_snowflake_connection_test.go new file mode 100644 index 0000000..44089a5 --- /dev/null +++ b/provider/resource_snowflake_connection_test.go @@ -0,0 +1,103 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccSnowflakeConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccSnowflakeConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccSnowflakeConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccSnowflakeConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccSnowflakeConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_snowflake_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccSnowflakeConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_snowflake_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_snowflake_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccSnowflakeConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_snowflake_connection" "test" { + name = "%s" + configuration = { + account = "acme" + username = "user" + password = "secret" + dbname = "db" + warehouse = "warehouse" + } +} +`, name) +} + +func testAccSnowflakeConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_snowflake_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccSnowflakeConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_snowflake_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_sqlserver_connection_test.go b/provider/resource_sqlserver_connection_test.go new file mode 100644 index 0000000..f44ef9e --- /dev/null +++ b/provider/resource_sqlserver_connection_test.go @@ -0,0 +1,103 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccSqlserverConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccSqlserverConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccSqlserverConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccSqlserverConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccSqlserverConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_sqlserver_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccSqlserverConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_sqlserver_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_sqlserver_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccSqlserverConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_sqlserver_connection" "test" { + name = "%s" + configuration = { + hostname = "sqlserver.azure.example.com" + username = "polytomic" + password = "secret" + database = "acme" + port = 1443 + } +} +`, name) +} + +func testAccSqlserverConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_sqlserver_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccSqlserverConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_sqlserver_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_statsig_connection_test.go b/provider/resource_statsig_connection_test.go new file mode 100644 index 0000000..26331dd --- /dev/null +++ b/provider/resource_statsig_connection_test.go @@ -0,0 +1,99 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccStatsigConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccStatsigConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccStatsigConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccStatsigConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccStatsigConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_statsig_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccStatsigConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_statsig_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_statsig_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccStatsigConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_statsig_connection" "test" { + name = "%s" + configuration = { + api_key = "my-api-key" + } +} +`, name) +} + +func testAccStatsigConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_statsig_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccStatsigConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_statsig_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_stripe_connection_test.go b/provider/resource_stripe_connection_test.go new file mode 100644 index 0000000..a9f9943 --- /dev/null +++ b/provider/resource_stripe_connection_test.go @@ -0,0 +1,99 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccStripeConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccStripeConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccStripeConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccStripeConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccStripeConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_stripe_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccStripeConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_stripe_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_stripe_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccStripeConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_stripe_connection" "test" { + name = "%s" + configuration = { + api_key = "my-api-key" + } +} +`, name) +} + +func testAccStripeConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_stripe_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccStripeConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_stripe_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_survicate_connection_test.go b/provider/resource_survicate_connection_test.go new file mode 100644 index 0000000..ac3eb5b --- /dev/null +++ b/provider/resource_survicate_connection_test.go @@ -0,0 +1,99 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccSurvicateConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccSurvicateConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccSurvicateConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccSurvicateConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccSurvicateConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_survicate_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccSurvicateConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_survicate_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_survicate_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccSurvicateConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_survicate_connection" "test" { + name = "%s" + configuration = { + api_key = "my-api-key" + } +} +`, name) +} + +func testAccSurvicateConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_survicate_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccSurvicateConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_survicate_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_synapse_connection_test.go b/provider/resource_synapse_connection_test.go new file mode 100644 index 0000000..8d5e385 --- /dev/null +++ b/provider/resource_synapse_connection_test.go @@ -0,0 +1,103 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccSynapseConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccSynapseConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccSynapseConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccSynapseConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccSynapseConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_synapse_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccSynapseConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_synapse_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_synapse_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccSynapseConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_synapse_connection" "test" { + name = "%s" + configuration = { + hostname = "host.example.com" + username = "user" + password = "password" + database = "database" + port = 5439 + } +} +`, name) +} + +func testAccSynapseConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_synapse_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccSynapseConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_synapse_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_uservoice_connection_test.go b/provider/resource_uservoice_connection_test.go new file mode 100644 index 0000000..00aeb48 --- /dev/null +++ b/provider/resource_uservoice_connection_test.go @@ -0,0 +1,100 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccUservoiceConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccUservoiceConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccUservoiceConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccUservoiceConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccUservoiceConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_uservoice_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccUservoiceConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_uservoice_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_uservoice_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccUservoiceConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_uservoice_connection" "test" { + name = "%s" + configuration = { + api_key = "my-api-key" + domain = "example.com" + } +} +`, name) +} + +func testAccUservoiceConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_uservoice_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccUservoiceConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_uservoice_connection" "test" { + name = "%s" + configuration = {} +}`, name) +} diff --git a/provider/resource_vanilla_connection_test.go b/provider/resource_vanilla_connection_test.go new file mode 100644 index 0000000..acaf9c4 --- /dev/null +++ b/provider/resource_vanilla_connection_test.go @@ -0,0 +1,100 @@ +// Code generated by Polytomic. DO NOT EDIT. +// edit connections.yaml and re-run go generate + +package provider + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccVanillaConnection(t *testing.T) { + name := "TestAcc" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Missing configuration + { + Config: testAccVanillaConnectionResourceNoConfig(name), + ExpectError: regexp.MustCompile("The argument \"configuration\" is required, but no definition was found."), + }, + // Empty configuration + { + Config: testAccVanillaConnectionResourceMissingRequired(name), + ExpectError: regexp.MustCompile("Inappropriate value for attribute \"configuration\":"), + }, + { + Config: testAccVanillaConnectionResource(name), + Check: resource.ComposeTestCheckFunc( + // Check if the resource exists + testAccVanillaConnectionExists(name), + // Check the name + resource.TestCheckResourceAttr("polytomic_vanilla_connection.test", "name", name), + ), + }, + }, + }) +} + +func testAccVanillaConnectionExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + _, ok := s.RootModule().Resources["polytomic_vanilla_connection.test"] + if !ok { + return fmt.Errorf("not found: %s", "polytomic_vanilla_connection.test") + } + + client := testClient() + connections, err := client.Connections().List(context.TODO()) + if err != nil { + return err + } + var found bool + for _, connection := range connections { + if connection.Name == name { + found = true + break + } + } + + if !found { + return fmt.Errorf("connection %s not found", name) + } + + return nil + + } +} + +func testAccVanillaConnectionResource(name string) string { + return fmt.Sprintf(` +resource "polytomic_vanilla_connection" "test" { + name = "%s" + configuration = { + api_key = "my-api-key" + domain = "example.com" + } +} +`, name) +} + +func testAccVanillaConnectionResourceNoConfig(name string) string { + return fmt.Sprintf(` +resource "polytomic_vanilla_connection" "test" { + name = "%s" +} +`, name) +} + +func testAccVanillaConnectionResourceMissingRequired(name string) string { + return fmt.Sprintf(` +resource "polytomic_vanilla_connection" "test" { + name = "%s" + configuration = {} +}`, name) +}