Skip to content

Commit

Permalink
Add basic acceptence tests for kafka_cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
Mongey committed Mar 16, 2021
1 parent 9e69761 commit 4bae913
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/acc_test.yml
Original file line number Diff line number Diff line change
@@ -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
64 changes: 64 additions & 0 deletions ccloud/resource_kafka_cluster_test.go
Original file line number Diff line number Diff line change
@@ -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
}
`

0 comments on commit 4bae913

Please sign in to comment.