Skip to content

Commit

Permalink
added regression test for validatingwebhookconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
dak1n1 committed Oct 17, 2020
1 parent 85bdb96 commit 374e23f
Show file tree
Hide file tree
Showing 36 changed files with 825 additions and 581 deletions.
8 changes: 4 additions & 4 deletions kubernetes/resource_kubernetes_api_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ func TestAccKubernetesAPIService_basic(t *testing.T) {
name := fmt.Sprintf("%s.%s", version, group)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_api_service.test",
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesAPIServiceDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_api_service.test",
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesAPIServiceDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesAPIServiceConfig_basic(name, group, version),
Expand Down
20 changes: 9 additions & 11 deletions kubernetes/resource_kubernetes_certificate_signing_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ func TestAccKubernetesCertificateSigningRequest_basic(t *testing.T) {
usages := []string{"client auth"}
signerName := "kubernetes.io/legacy-unknown"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_certificate_signing_request.test",
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesCertificateSigningRequestDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_certificate_signing_request.test",
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesCertificateSigningRequestDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesCertificateSigningRequestConfig_basic(name, signerName, usages, true),
Expand All @@ -33,10 +33,10 @@ func TestAccKubernetesCertificateSigningRequest_basic(t *testing.T) {
func TestAccKubernetesCertificateSigningRequest_generateName(t *testing.T) {
generateName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_certificate_signing_request.test",
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesCertificateSigningRequestDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_certificate_signing_request.test",
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesCertificateSigningRequestDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesCertificateSigningRequestConfig_generateName(generateName),
Expand All @@ -62,9 +62,7 @@ func testAccCheckKubernetesCertificateSigningRequestValid(s *terraform.State) er
}

func testAccCheckKubernetesCertificateSigningRequestRemoteResourceDeleted(s *terraform.State) error {
providerInit, _ := testAccProviderFactories["kubernetes"]
prov, _ := providerInit()
conn, err := prov.Meta().(KubeClientsets).MainClientset()
conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset()

if err != nil {
return err
Expand Down
36 changes: 17 additions & 19 deletions kubernetes/resource_kubernetes_cluster_role_binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ func TestAccKubernetesClusterRoleBinding_basic(t *testing.T) {
name := fmt.Sprintf("tf-acc-test:%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_cluster_role_binding.test",
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesClusterRoleBindingDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_cluster_role_binding.test",
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesClusterRoleBindingDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesClusterRoleBindingConfig_basic(name),
Expand Down Expand Up @@ -128,10 +128,10 @@ func TestAccKubernetesClusterRoleBinding_serviceaccount_subject(t *testing.T) {
name := fmt.Sprintf("tf-acc-test:%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_cluster_role_binding.test",
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesClusterRoleBindingDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_cluster_role_binding.test",
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesClusterRoleBindingDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesClusterRoleBindingConfig_serviceaccount_subject(name),
Expand Down Expand Up @@ -161,10 +161,10 @@ func TestAccKubernetesClusterRoleBinding_group_subject(t *testing.T) {
name := fmt.Sprintf("tf-acc-test:%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))
resourceName := "kubernetes_cluster_role_binding.test"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_cluster_role_binding.test",
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesClusterRoleBindingDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_cluster_role_binding.test",
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesClusterRoleBindingDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesClusterRoleBindingConfig_group_subject(name),
Expand Down Expand Up @@ -199,10 +199,10 @@ func TestAccKubernetesClusterRoleBinding_UpdatePatchOperationsOrderWithRemovals(
name := fmt.Sprintf("tf-acc-test:%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_cluster_role_binding.test",
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesClusterRoleBindingDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_cluster_role_binding.test",
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesClusterRoleBindingDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesClusterRoleBindingConfigBug_step_0(name),
Expand Down Expand Up @@ -284,9 +284,7 @@ func TestAccKubernetesClusterRoleBinding_UpdatePatchOperationsOrderWithRemovals(
}

func testAccCheckKubernetesClusterRoleBindingDestroy(s *terraform.State) error {
providerInit, _ := testAccProviderFactories["kubernetes"]
prov, _ := providerInit()
conn, err := prov.Meta().(KubeClientsets).MainClientset()
conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset()

if err != nil {
return err
Expand Down
36 changes: 17 additions & 19 deletions kubernetes/resource_kubernetes_cluster_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ func TestAccKubernetesClusterRole_basic(t *testing.T) {
resourceName := "kubernetes_cluster_role.test"
name := acctest.RandomWithPrefix("tf-acc-test")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesClusterRoleDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesClusterRoleDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesClusterRoleConfig_basic(name),
Expand Down Expand Up @@ -69,10 +69,10 @@ func TestAccKubernetesClusterRole_UpdatePatchOperationsOrderWithRemovals(t *test
resourceName := "kubernetes_cluster_role.test"
name := acctest.RandomWithPrefix("tf-acc-test")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesClusterRoleDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesClusterRoleDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesClusterRoleConfigBug_step_0(name),
Expand Down Expand Up @@ -143,10 +143,10 @@ func TestAccKubernetesClusterRole_aggregationRuleBasic(t *testing.T) {
resourceName := "kubernetes_cluster_role.test"
name := acctest.RandomWithPrefix("tf-acc-test")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesClusterRoleDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesClusterRoleDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesClusterRoleConfig_aggRule(name),
Expand Down Expand Up @@ -187,10 +187,10 @@ func TestAccKubernetesClusterRole_aggregationRuleRuleAggregation(t *testing.T) {
resourceName := "kubernetes_cluster_role.test"
name := acctest.RandomWithPrefix("tf-acc-test")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesClusterRoleDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesClusterRoleDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesClusterRoleConfig_aggRule2(name),
Expand All @@ -216,9 +216,7 @@ func TestAccKubernetesClusterRole_aggregationRuleRuleAggregation(t *testing.T) {
}

func testAccCheckKubernetesClusterRoleDestroy(s *terraform.State) error {
providerInit, _ := testAccProviderFactories["kubernetes"]
prov, _ := providerInit()
conn, err := prov.Meta().(KubeClientsets).MainClientset()
conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset()

if err != nil {
return err
Expand Down
28 changes: 13 additions & 15 deletions kubernetes/resource_kubernetes_config_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ func TestAccKubernetesConfigMap_basic(t *testing.T) {
resourceName := "kubernetes_config_map.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesConfigMapDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesConfigMapDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesConfigMapConfig_nodata(name),
Expand Down Expand Up @@ -127,10 +127,10 @@ func TestAccKubernetesConfigMap_binaryData(t *testing.T) {
resourceName := "kubernetes_config_map.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesConfigMapDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesConfigMapDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesConfigMapConfig_binaryData(prefix),
Expand Down Expand Up @@ -161,10 +161,10 @@ func TestAccKubernetesConfigMap_generatedName(t *testing.T) {
resourceName := "kubernetes_config_map.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesConfigMapDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesConfigMapDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesConfigMapConfig_generatedName(prefix),
Expand Down Expand Up @@ -205,9 +205,7 @@ func testAccCheckConfigMapData(m *api.ConfigMap, expected map[string]string) res
}

func testAccCheckKubernetesConfigMapDestroy(s *terraform.State) error {
providerInit, _ := testAccProviderFactories["kubernetes"]
prov, _ := providerInit()
conn, err := prov.Meta().(KubeClientsets).MainClientset()
conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset()

if err != nil {
return err
Expand Down
20 changes: 9 additions & 11 deletions kubernetes/resource_kubernetes_cron_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ func TestAccKubernetesCronJob_basic(t *testing.T) {
name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_cron_job.test",
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesCronJobDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_cron_job.test",
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesCronJobDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesCronJobConfig_basic(name),
Expand Down Expand Up @@ -77,10 +77,10 @@ func TestAccKubernetesCronJob_extra(t *testing.T) {
name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_cron_job.test",
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesCronJobDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_cron_job.test",
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesCronJobDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesCronJobConfig_extra(name),
Expand Down Expand Up @@ -113,9 +113,7 @@ func TestAccKubernetesCronJob_extra(t *testing.T) {
}

func testAccCheckKubernetesCronJobDestroy(s *terraform.State) error {
providerInit, _ := testAccProviderFactories["kubernetes"]
prov, _ := providerInit()
conn, err := prov.Meta().(KubeClientsets).MainClientset()
conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset()

if err != nil {
return err
Expand Down
12 changes: 5 additions & 7 deletions kubernetes/resource_kubernetes_csi_driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ func TestAccKubernetesCSIDriver_basic(t *testing.T) {
name := acctest.RandomWithPrefix("tf-acc-test")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesCSIDriverDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesCSIDriverDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesCSIDriverBasicConfig(name, true),
Expand All @@ -45,9 +45,7 @@ func TestAccKubernetesCSIDriver_basic(t *testing.T) {
}

func testAccCheckKubernetesCSIDriverDestroy(s *terraform.State) error {
providerInit, _ := testAccProviderFactories["kubernetes"]
prov, _ := providerInit()
conn, err := prov.Meta().(KubeClientsets).MainClientset()
conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset()

if err != nil {
return err
Expand Down
12 changes: 5 additions & 7 deletions kubernetes/resource_kubernetes_daemonset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ func TestAccKubernetesDaemonSet_minimal(t *testing.T) {
name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_daemonset.test",
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesDaemonSetDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_daemonset.test",
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesDaemonSetDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesDaemonSetConfig_minimal(name),
Expand Down Expand Up @@ -261,9 +261,7 @@ func TestAccKubernetesDaemonSet_with_tolerations_unset_toleration_seconds(t *tes
}

func testAccCheckKubernetesDaemonSetDestroy(s *terraform.State) error {
providerInit, _ := testAccProviderFactories["kubernetes"]
prov, _ := providerInit()
conn, err := prov.Meta().(KubeClientsets).MainClientset()
conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset()

if err != nil {
return err
Expand Down
16 changes: 8 additions & 8 deletions kubernetes/resource_kubernetes_default_service_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ func TestAccKubernetesDefaultServiceAccount_basic(t *testing.T) {
resourceName := "kubernetes_default_service_account.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesServiceAccountDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesServiceAccountDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesDefaultServiceAccountConfig_basic(namespace),
Expand Down Expand Up @@ -63,10 +63,10 @@ func TestAccKubernetesDefaultServiceAccount_secrets(t *testing.T) {
namespace := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_default_service_account.test",
Providers: testAccProviders,
CheckDestroy: testAccCheckKubernetesServiceAccountDestroy,
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "kubernetes_default_service_account.test",
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckKubernetesServiceAccountDestroy,
Steps: []resource.TestStep{
{
Config: testAccKubernetesDefaultServiceAccountConfig_secrets(namespace),
Expand Down
Loading

0 comments on commit 374e23f

Please sign in to comment.