From 8fa0fbf8655a58e973a93bbe2e69bb86bca3bb55 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Mon, 13 May 2024 11:06:48 -0400 Subject: [PATCH] fix: add test case to validate empty provider (#206) --- provider/provider_test.go | 34 ++++++++++++++++++++++++++++++++++ provider/provisioner_test.go | 1 + 2 files changed, 35 insertions(+) diff --git a/provider/provider_test.go b/provider/provider_test.go index cd00f9a4..c1e3c686 100644 --- a/provider/provider_test.go +++ b/provider/provider_test.go @@ -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" @@ -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 + }, + }}, + }) +} diff --git a/provider/provisioner_test.go b/provider/provisioner_test.go index e9f83e43..f1521ef9 100644 --- a/provider/provisioner_test.go +++ b/provider/provisioner_test.go @@ -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(),