diff --git a/.github/workflows/acc_test.yml b/.github/workflows/acc_test.yml new file mode 100644 index 0000000..eab00d8 --- /dev/null +++ b/.github/workflows/acc_test.yml @@ -0,0 +1,20 @@ +name: acc_test + +on: workflow_dispatch + +jobs: + test: + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v1 + with: + go-version: 1.16.x + - name: Acceptence Tests + env: # Or as an environment variable + CONFLUENT_CLOUD_USERNAME: ${{ secrets.CONFLUENT_CLOUD_USERNAME }} + CONFLUENT_CLOUD_PASSWORD: ${{ secrets.CONFLUENT_CLOUD_PASSWORD }} + run: make testacc diff --git a/ccloud/resource_kafka_cluster_test.go b/ccloud/resource_kafka_cluster_test.go new file mode 100644 index 0000000..baf6ed3 --- /dev/null +++ b/ccloud/resource_kafka_cluster_test.go @@ -0,0 +1,64 @@ +package ccloud + +import ( + "fmt" + "os" + "testing" + + "github.com/hashicorp/go-uuid" + r "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func overrideProvider() *schema.Provider { + return Provider() +} +func accProvider() map[string]*schema.Provider { + return map[string]*schema.Provider{ + "confluentcloud": overrideProvider(), + } +} + +func testAccPreCheck(t *testing.T) { + if os.Getenv("CONFLUENT_CLOUD_USERNAME") == "" || os.Getenv("CONFLUENT_CLOUD_PASSWORD") == "" { + t.Skip("CONFLUENT_CLOUD_ environment variables must be set") + } +} + +func TestAcc_BasicCluster(t *testing.T) { + u, err := uuid.GenerateUUID() + if err != nil { + t.Fatal(err) + } + + r.ParallelTest(t, r.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: accProvider(), + Steps: []r.TestStep{ + { + Config: fmt.Sprintf(testResourceCluster_noConfig, u, u), + }, + }, + }) +} + +//lintignore:AT004 +const testResourceCluster_noConfig = ` +resource "confluentcloud_environment" "test" { + name = "acc_test_environment-%s" +} + +resource "confluentcloud_kafka_cluster" "test" { + name = "provider-test-%s" + service_provider = "aws" + region = "eu-west-1" + availability = "LOW" + environment_id = confluentcloud_environment.test.id + deployment = { + sku = "BASIC" + } + network_egress = 100 + network_ingress = 100 + storage = 5000 +} +`