Skip to content

Commit

Permalink
fix: add test case to validate empty provider (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecarbs authored May 13, 2024
1 parent 3cc9802 commit 8fa0fbf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
34 changes: 34 additions & 0 deletions provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package provider_test
import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/stretchr/testify/require"

"github.com/coder/terraform-provider-coder/provider"
Expand All @@ -14,3 +17,34 @@ func TestProvider(t *testing.T) {
err := tfProvider.InternalValidate()
require.NoError(t, err)
}

// TestProviderEmpty ensures that the provider can be configured without
// any actual input data. This is important for adding new fields
// with backwards compatibility guarantees.
func TestProviderEmpty(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
Providers: map[string]*schema.Provider{
"coder": provider.New(),
},
IsUnitTest: true,
Steps: []resource.TestStep{{
Config: `
provider "coder" {}
data "coder_provisioner" "me" {}
data "coder_workspace" "me" {}
data "coder_external_auth" "git" {
id = "git"
}
data "coder_git_auth" "git" {
id = "git"
}
data "coder_parameter" "param" {
name = "hey"
}`,
Check: func(state *terraform.State) error {
return nil
},
}},
})
}
1 change: 1 addition & 0 deletions provider/provisioner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

func TestProvisioner(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
Providers: map[string]*schema.Provider{
"coder": provider.New(),
Expand Down

0 comments on commit 8fa0fbf

Please sign in to comment.