Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dak1n1 committed Feb 19, 2021
1 parent 34c0e78 commit 6dca5d8
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions kubernetes/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ var testAccProviderFactoriesInternal = map[string]func() (*schema.Provider, erro
},
}

func TestAccKubernetesProvider_config_path(t *testing.T) {
func TestAccKubernetesProviderConfig_config_path(t *testing.T) {

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheckInternal(t) },
Expand Down Expand Up @@ -559,7 +559,7 @@ func TestAccKubernetesProvider_config_path(t *testing.T) {
})
}

func TestAccKubernetesProvider_config_paths(t *testing.T) {
func TestAccKubernetesProviderConfig_config_paths(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheckInternal(t) },
ProviderFactories: testAccProviderFactoriesInternal,
Expand Down Expand Up @@ -600,7 +600,7 @@ func TestAccKubernetesProvider_config_paths(t *testing.T) {
})
}

func TestAccKubernetesProvider_config_paths_env(t *testing.T) {
func TestAccKubernetesProviderConfig_config_paths_env(t *testing.T) {

resource.Test(t, resource.TestCase{
PreCheck: func() {
Expand All @@ -627,7 +627,7 @@ func TestAccKubernetesProvider_config_paths_env(t *testing.T) {
})
}

func TestAccKubernetesProvider_config_paths_env_wantError(t *testing.T) {
func TestAccKubernetesProviderConfig_config_paths_env_wantError(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheckInternal_setEnv(t, map[string]string{
Expand All @@ -650,30 +650,30 @@ func TestAccKubernetesProvider_config_paths_env_wantError(t *testing.T) {
})
}

func TestAccKubernetesProvider_config_paths_host_env_wantError(t *testing.T) {
func TestAccKubernetesProviderConfig_host_env_wantError(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheckInternal_setEnv(t, map[string]string{
"KUBE_HOST": "test-host",
"KUBE_CONFIG_PATHS": strings.Join([]string{
"./testdata/kubeconfig",
"./testdata/kubeconfig",
}, string(os.PathListSeparator)),
"KUBE_HOST": "test-host",
})
},
ProviderFactories: testAccProviderFactoriesInternal,
Steps: []resource.TestStep{
{
Config: testAccKubernetesProviderConfig("# empty"),
ExpectError: regexp.MustCompile(`"config_paths": conflicts with host`),
ExpectError: regexp.MustCompile(`"host": conflicts with config_paths`),
PlanOnly: true,
ExpectNonEmptyPlan: true,
},
},
})
}

func TestAccKubernetesProvider_host(t *testing.T) {
func TestAccKubernetesProviderConfig_host(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheckInternal(t) },
ProviderFactories: testAccProviderFactoriesInternal,
Expand Down Expand Up @@ -723,13 +723,22 @@ func TestAccKubernetesProvider_host(t *testing.T) {
{
Config: testAccKubernetesProviderConfig(
providerConfig_exec("test-exec") +
providerConfig_token("test-token"),
providerConfig_cluster_ca_certificate("test-ca-cert"),
),
PlanOnly: true,
ExpectNonEmptyPlan: true,
// Error: "exec": all of `cluster_ca_certificate,exec,host` must be specified
ExpectError: regexp.MustCompile("cluster_ca_certificate,exec,host"),
},
{
Config: testAccKubernetesProviderConfig(
providerConfig_exec("test-exec") +
providerConfig_host("https://test-host") +
providerConfig_cluster_ca_certificate("test-ca-cert"),
),
PlanOnly: true,
ExpectNonEmptyPlan: true,
},
{
Config: testAccKubernetesProviderConfig(
providerConfig_token("test-token"),
Expand Down Expand Up @@ -765,6 +774,17 @@ func TestAccKubernetesProvider_host(t *testing.T) {
PlanOnly: true,
ExpectNonEmptyPlan: true,
},
{
Config: testAccKubernetesProviderConfig(
providerConfig_host("https://test-host") +
providerConfig_cluster_ca_certificate("test-ca-cert") +
providerConfig_client_cert("test-client-cert"),
),
PlanOnly: true,
ExpectNonEmptyPlan: true,
// Error: "client_certificate": all of `client_certificate,client_key,cluster_ca_certificate,host` must be specified
ExpectError: regexp.MustCompile("client_certificate,client_key,cluster_ca_certificate,host"),
},
},
})
}
Expand Down

0 comments on commit 6dca5d8

Please sign in to comment.