Skip to content

Commit

Permalink
test: add ACC test with model
Browse files Browse the repository at this point in the history
  • Loading branch information
anvial committed Oct 7, 2024
1 parent 8da2f56 commit 92669a6
Showing 1 changed file with 17 additions and 28 deletions.
45 changes: 17 additions & 28 deletions internal/provider/resource_kubernetes_cloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ func TestAcc_ResourceKubernetesCloud(t *testing.T) {
t.Skip(t.Name() + " only runs with LXD")
}
cloudName := acctest.RandomWithPrefix("tf-test-k8scloud")
modelName := acctest.RandomWithPrefix("tf-test-model")
cloudConfig := os.Getenv("MICROK8S_CONFIG")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: frameworkProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccResourceKubernetesCloudWithoutModel(cloudName, cloudConfig),
Config: testAccResourceKubernetesCloud(cloudName, modelName, cloudConfig),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("juju_kubernetes_cloud."+cloudName, "name", cloudName),
),
Expand All @@ -33,39 +34,27 @@ func TestAcc_ResourceKubernetesCloud(t *testing.T) {
})
}

//func testAccResourceKubernetesCloud(cloudName string, modelName string, config string) string {
// return internaltesting.GetStringFromTemplateWithData(
// "testAccResourceSecret",
// `
//resource "juju_kubernetes_cloud" {{.CloudName}} {
// name = "{{.CloudName}}"
// kubernetes_config = {{.Config}}
//}
//
//resource "juju_model" {{.ModelName}} {
// name = "{{.ModelName}}"
// credential = juju_kubernetes_cloud.{{.CloudName}}.credential
// cloud {
// name = juju_kubernetes_cloud.{{.CloudName}}.name
// }
//}
//`, internaltesting.TemplateData{
// "CloudName": cloudName,
// "ModelName": modelName,
// "Config": config,
// })
//}

func testAccResourceKubernetesCloudWithoutModel(cloudName string, config string) string {
func testAccResourceKubernetesCloud(cloudName string, modelName string, config string) string {
return internaltesting.GetStringFromTemplateWithData(
"testAccResourceSecret",
`
resource "juju_kubernetes_cloud" {{.CloudName}} {
name = "{{.CloudName}}"
kubernetes_config = {{.Config}}
resource "juju_kubernetes_cloud" "tf-test-k8scloud" {
name = "{{.CloudName}}"
kubernetes_config = {{.Config}}
}
resource "juju_model" {{.ModelName}} {
name = "{{.ModelName}}"
credential = juju_kubernetes_cloud.tf-test-k8scloud.credential
cloud {
name = juju_kubernetes_cloud.tf-test-k8scloud.name
}
}
`, internaltesting.TemplateData{
"CloudName": cloudName,
"ModelName": modelName,
"Config": config,
})
}

0 comments on commit 92669a6

Please sign in to comment.