Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Julien DOCHE <[email protected]>
  • Loading branch information
St0rmingBr4in committed Oct 12, 2022
1 parent b9ef776 commit b56fb23
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
12 changes: 6 additions & 6 deletions manifest/test/acceptance/datasource_resource_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import (
"testing"

"github.com/hashicorp/go-hclog"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-provider-kubernetes/manifest/provider"
"github.com/hashicorp/terraform-provider-kubernetes/manifest/test/helper/kubernetes"

tfstatehelper "github.com/hashicorp/terraform-provider-kubernetes/manifest/test/helper/state"
)

func TestDataSourceKubernetesResource_ConfigMap(t *testing.T) {
func TestDataSourceKubernetesResourceStatus_Deployment(t *testing.T) {
ctx := context.Background()

reattachInfo, err := provider.ServeTest(ctx, hclog.Default(), t)
Expand All @@ -35,7 +34,7 @@ func TestDataSourceKubernetesResource_ConfigMap(t *testing.T) {
defer func() {
tf.Destroy(ctx)
tf.Close()
k8shelper.AssertNamespacedResourceDoesNotExist(t, "v1", "configmaps", namespace, name)
k8shelper.AssertNamespacedResourceDoesNotExist(t, "apps/v1", "deployments", namespace, name)
}()

tfvars := TFVARS{
Expand All @@ -47,7 +46,8 @@ func TestDataSourceKubernetesResource_ConfigMap(t *testing.T) {
tf.Init(ctx)
tf.Apply(ctx)

k8shelper.AssertNamespacedResourceExists(t, "v1", "deployments", namespace, name)

k8shelper.AssertNamespacedResourceExists(t, "apps/v1", "deployments", namespace, name)

state, err := tf.State(ctx)
if err != nil {
Expand All @@ -65,7 +65,7 @@ func TestDataSourceKubernetesResource_ConfigMap(t *testing.T) {
defer func() {
step2.Destroy(ctx)
step2.Close()
k8shelper.AssertNamespacedResourceDoesNotExist(t, "v1", "deployments", namespace, name2)
k8shelper.AssertNamespacedResourceDoesNotExist(t, "apps/v1", "deployments", namespace, name)
}()

tfconfig = loadTerraformConfig(t, "datasource-resource-status/step2.tf", tfvars)
Expand All @@ -77,7 +77,7 @@ func TestDataSourceKubernetesResource_ConfigMap(t *testing.T) {
if err != nil {
t.Fatalf("Failed to retrieve terraform state: %q", err)
}
tfstate := tfstatehelper.NewHelper(s2)
tfstate = tfstatehelper.NewHelper(s2)

// check that the data source has the status field defined
tfstate.AssertAttributeNotEmpty(t, "data.kubernetes_resource.test_deploy.object.status")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
resource "kubernetes_deployment" "test_deploy" {
api_version = "v1"

metadata = {
name = var.name
namespace = var.namespace
}

spec {
replicas = 1

selector {
match_labels = {
test = "test-status"
}
resource "kubernetes_manifest" "test_deploy" {
manifest = {
"apiVersion" = "apps/v1"
"kind" = "Deployment"
"metadata" = {
"name" = var.name
"namespace" = var.namespace
}

template {
metadata {
labels = {
test = "test-status"
"spec" = {
"selector" = {
"matchLabels" = {
"test" = "MyExampleApp"
}
}

spec {
container {
image = "nginx:1.21.6"
name = "test"
"template" = {
"metadata" = {
"labels" = {
"test" = "MyExampleApp"
}
}

"spec" = {
"containers" = [
{
"image" = "nginx:1.21.6"
"name" = "example"
}
]
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
data "kubernetes_resource" "test_deploy" {
api_version = "v1"
api_version = "apps/v1"
kind = "Deployment"
metadata {
name = var.name
Expand Down

0 comments on commit b56fb23

Please sign in to comment.