From 3283edd167873416531c1b1e0a4886b73f8fe964 Mon Sep 17 00:00:00 2001 From: Ethan Dickson Date: Fri, 21 Feb 2025 02:45:17 +0000 Subject: [PATCH] fix: use server computed org display name --- internal/provider/organization_resource.go | 1 - .../provider/organization_resource_test.go | 23 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/internal/provider/organization_resource.go b/internal/provider/organization_resource.go index 2c39f0c..212f3af 100644 --- a/internal/provider/organization_resource.go +++ b/internal/provider/organization_resource.go @@ -119,7 +119,6 @@ This resource is only compatible with Coder version [2.16.0](https://github.com/ MarkdownDescription: "Display name of the organization. Defaults to name.", Computed: true, Optional: true, - Default: stringdefault.StaticString(""), Validators: []validator.String{ codersdkvalidator.DisplayName(), }, diff --git a/internal/provider/organization_resource_test.go b/internal/provider/organization_resource_test.go index 0a755c4..3b5262b 100644 --- a/internal/provider/organization_resource_test.go +++ b/internal/provider/organization_resource_test.go @@ -99,6 +99,29 @@ func TestAccOrganizationResource(t *testing.T) { }, }) }) + + t.Run("DefaultDisplayName", func(t *testing.T) { + cfg1 := testAccOrganizationResourceConfig{ + URL: client.URL.String(), + Token: client.SessionToken(), + Name: ptr.Ref("example-org"), + Description: ptr.Ref("This is an example organization"), + Icon: ptr.Ref("/icon/coder.svg"), + } + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: cfg1.String(t), + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue("coderd_organization.test", tfjsonpath.New("display_name"), knownvalue.StringExact("example-org")), + }, + }, + }, + }) + }) } type testAccOrganizationResourceConfig struct {