Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite5afa40

Browse files
fix: use server computed org display name (#183)
I picked up on this reviewing#182, but it's a mistake I made whenreviewing the resource originally 😓There's a minor inconsistency between display names on orgs and someother resources with display names on `coderd`. i.e. for organizations:```if req.DisplayName == "" {req.DisplayName = req.Name}```For some other resources, e.g. users & groups, an empty string displayname is retained, and the CLI/Web UI just shows the actual name if thedisplay name is empty. For those, it's okay to have an empty stringdefault in the provider.
1 parented8270c commite5afa40

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

‎internal/provider/organization_resource.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ This resource is only compatible with Coder version [2.16.0](https://github.com/
121121
MarkdownDescription:"Display name of the organization. Defaults to name.",
122122
Computed:true,
123123
Optional:true,
124-
Default:stringdefault.StaticString(""),
125124
Validators: []validator.String{
126125
codersdkvalidator.DisplayName(),
127126
},

‎internal/provider/organization_resource_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,29 @@ func TestAccOrganizationResource(t *testing.T) {
121121
},
122122
})
123123
})
124+
125+
t.Run("DefaultDisplayName",func(t*testing.T) {
126+
cfg1:=testAccOrganizationResourceConfig{
127+
URL:client.URL.String(),
128+
Token:client.SessionToken(),
129+
Name:ptr.Ref("example-org"),
130+
Description:ptr.Ref("This is an example organization"),
131+
Icon:ptr.Ref("/icon/coder.svg"),
132+
}
133+
resource.Test(t, resource.TestCase{
134+
IsUnitTest:true,
135+
PreCheck:func() {testAccPreCheck(t) },
136+
ProtoV6ProviderFactories:testAccProtoV6ProviderFactories,
137+
Steps: []resource.TestStep{
138+
{
139+
Config:cfg1.String(t),
140+
ConfigStateChecks: []statecheck.StateCheck{
141+
statecheck.ExpectKnownValue("coderd_organization.test",tfjsonpath.New("display_name"),knownvalue.StringExact("example-org")),
142+
},
143+
},
144+
},
145+
})
146+
})
124147
}
125148

126149
typetestAccOrganizationResourceConfigstruct {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp