Skip to content

Commit

Permalink
fix(cloud): resolve acceptance test issues by removing model
Browse files Browse the repository at this point in the history
- Modified `resource_kubernetes_cloud_test.go` to adjust acceptance tests for Kubernetes cloud, removing the model and ensuring tests run with LXD.
  • Loading branch information
anvial committed Oct 17, 2024
1 parent 6e93012 commit 5c8dbfc
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions internal/provider/resource_kubernetes_cloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,53 +13,36 @@ import (
)

func TestAcc_ResourceKubernetesCloud(t *testing.T) {
// TODO: Skip this ACC test until we have a way to run correctly with kubernetes_config
// attribute set to a correct k8s config in github action environment
t.Skip(t.Name() + " is skipped until we have a way to run correctly with kubernetes_config attribute set to a correct k8s config in github action environment")

if testingCloud != LXDCloudTesting {
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: testAccResourceKubernetesCloud(cloudName, modelName, cloudConfig),
Config: testAccResourceKubernetesCloudWithoutModel(cloudName, cloudConfig),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("juju_kubernetes_cloud."+cloudName, "name", cloudName),
resource.TestCheckResourceAttr("juju_kubernetes_cloud."+cloudName, "model", modelName),
),
},
},
})
}

func testAccResourceKubernetesCloud(cloudName string, modelName string, config string) string {
func testAccResourceKubernetesCloudWithoutModel(cloudName string, config string) string {
return internaltesting.GetStringFromTemplateWithData(
"testAccResourceSecret",
`
resource "juju_kubernetes_cloud" "tf-test-k8scloud" {
name = "{{.CloudName}}"
kubernetes_config = file("~/microk8s-config.yaml")
}
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 5c8dbfc

Please sign in to comment.