-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds test for instance_secrets_data_source
- Loading branch information
1 parent
5f60ef7
commit add68e5
Showing
4 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package provider | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
) | ||
|
||
func TestInstanceSecretsDataSource(t *testing.T) { | ||
instanceName := generateInstanceName() | ||
orgId := os.Getenv("ORG_ID") | ||
|
||
resource.Test(t, resource.TestCase{ | ||
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, | ||
Steps: []resource.TestStep{ | ||
// Read testing | ||
{ | ||
Config: testProviderConfig() + testInstanceResourceCreateConfig(instanceName, orgId) + testInstanceSecretsCreateConfig(orgId), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr("data.tembo_instance_secrets.test_ds", "available_secrets.#", "4"), | ||
resource.TestCheckResourceAttr("data.tembo_instance_secrets.test_ds", "available_secrets.0.name", "app-role"), | ||
resource.TestCheckResourceAttr("data.tembo_instance_secrets.test_ds", "available_secrets.0.possible_keys.#", "2"), | ||
resource.TestCheckResourceAttr("data.tembo_instance_secrets.test_ds", "available_secrets.0.possible_keys.0", "username"), | ||
resource.TestCheckResourceAttr("data.tembo_instance_secrets.test_ds", "available_secrets.0.possible_keys.1", "password"), | ||
resource.TestCheckResourceAttr("data.tembo_instance_secrets.test_ds", "available_secrets.1.name", "readonly-role"), | ||
resource.TestCheckResourceAttr("data.tembo_instance_secrets.test_ds", "available_secrets.1.possible_keys.#", "2"), | ||
resource.TestCheckResourceAttr("data.tembo_instance_secrets.test_ds", "available_secrets.1.possible_keys.0", "username"), | ||
resource.TestCheckResourceAttr("data.tembo_instance_secrets.test_ds", "available_secrets.1.possible_keys.1", "password"), | ||
resource.TestCheckResourceAttr("data.tembo_instance_secrets.test_ds", "available_secrets.2.name", "superuser-role"), | ||
resource.TestCheckResourceAttr("data.tembo_instance_secrets.test_ds", "available_secrets.2.possible_keys.#", "2"), | ||
resource.TestCheckResourceAttr("data.tembo_instance_secrets.test_ds", "available_secrets.2.possible_keys.0", "username"), | ||
resource.TestCheckResourceAttr("data.tembo_instance_secrets.test_ds", "available_secrets.2.possible_keys.1", "password"), | ||
resource.TestCheckResourceAttr("data.tembo_instance_secrets.test_ds", "available_secrets.3.name", "certificate"), | ||
resource.TestCheckResourceAttr("data.tembo_instance_secrets.test_ds", "available_secrets.3.possible_keys.#", "1"), | ||
resource.TestCheckResourceAttr("data.tembo_instance_secrets.test_ds", "available_secrets.3.possible_keys.0", "ca.crt"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testInstanceSecretsCreateConfig(orgId string) string { | ||
return fmt.Sprintf(` | ||
data "tembo_instance_secrets" "test_ds" { | ||
org_id = "%v" | ||
instance_id = tembo_instance.test.instance_id | ||
}`, orgId) | ||
} |