Skip to content

Commit

Permalink
Fix the namespace acceptance tests
Browse files Browse the repository at this point in the history
Provider configuration has the wrong provider name as "tmc" instead of "tanzu-mission-control" causing the tests to fail. Modified the test to use the common provider testing code instead of the incorrect one.

Signed-off-by: Ramya Bangera <bangerar@vmware.com>
  • Loading branch information
ramya-bangera committed Feb 21, 2024
1 parent 61cf1f8 commit 19dc699
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 22 deletions.
4 changes: 2 additions & 2 deletions internal/resources/namespace/data_source_namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func TestAcceptanceForNamespaceDataSource(t *testing.T) {
resourceName := fmt.Sprintf("%s.%s", namespaceResource, namespaceResourceVar)

resource.Test(t, resource.TestCase{
PreCheck: testPreCheck(t),
ProviderFactories: getTestProviderFactories(provider),
PreCheck: testhelper.TestPreCheck(t),
ProviderFactories: testhelper.GetTestProviderFactories(provider),
CheckDestroy: nil,
Steps: []resource.TestStep{
{
Expand Down
18 changes: 0 additions & 18 deletions internal/resources/namespace/namespace_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ SPDX-License-Identifier: MPL-2.0
package namespace

import (
"os"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand All @@ -16,8 +15,6 @@ import (
"github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/cluster"
)

const providerName = "tmc"

func initTestProvider(t *testing.T) *schema.Provider {
testProvider := &schema.Provider{
Schema: authctx.ProviderAuthSchema(),
Expand All @@ -37,18 +34,3 @@ func initTestProvider(t *testing.T) *schema.Provider {

return testProvider
}

func testPreCheck(t *testing.T) func() {
return func() {
for _, env := range []string{authctx.ServerEndpointEnvVar, authctx.VMWCloudAPITokenEnvVar, authctx.VMWCloudEndpointEnvVar} {
require.NotEmpty(t, os.Getenv(env))
}
}
}

func getTestProviderFactories(provider *schema.Provider) map[string]func() (*schema.Provider, error) {
//nolint:unparam
return map[string]func() (*schema.Provider, error){
providerName: func() (*schema.Provider, error) { return provider, nil },
}
}
4 changes: 2 additions & 2 deletions internal/resources/namespace/resource_namepace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func TestAcceptanceForNamespaceResource(t *testing.T) {
clusterName := acctest.RandomWithPrefix("tf-cluster")

resource.Test(t, resource.TestCase{
PreCheck: testPreCheck(t),
ProviderFactories: getTestProviderFactories(provider),
PreCheck: testhelper.TestPreCheck(t),
ProviderFactories: testhelper.GetTestProviderFactories(provider),
CheckDestroy: nil,
Steps: []resource.TestStep{
{
Expand Down

0 comments on commit 19dc699

Please sign in to comment.