Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanndickson committed Jul 15, 2024
1 parent 0edeff0 commit cc62729
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 26 deletions.
4 changes: 2 additions & 2 deletions docs/data-sources/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ An existing user on the coder deployment

### Optional

- `id` (String) The ID of the user to retrieve. This field will be populated if a username is supplied
- `username` (String) The username of the user to retrieve. This field will be populated if an ID is supplied
- `id` (String) The ID of the user to retrieve. This field will be populated if a username is supplied.
- `username` (String) The username of the user to retrieve. This field will be populated if an ID is supplied.

### Read-Only

Expand Down
3 changes: 0 additions & 3 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider

import (
Expand Down
37 changes: 22 additions & 15 deletions internal/provider/user_data_source_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider

/*
import (
"html/template"
"strings"
"testing"
Expand All @@ -20,7 +18,7 @@ func TestAccUserDataSource(t *testing.T) {
{
Config: testAccUserDataSourceConfig{
Username: "example",
}.String(),
}.String(t),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("coderd_user.test", "username", "example"),
resource.TestCheckResourceAttr("coderd_user.test", "name", "Example User"),
Expand All @@ -43,7 +41,7 @@ func TestAccUserDataSource(t *testing.T) {
{
Config: testAccUserDataSourceConfig{
ID: "example",
}.String(),
}.String(t),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("coderd_user.test", "username", "example"),
resource.TestCheckResourceAttr("coderd_user.test", "name", "Example User"),
Expand All @@ -65,16 +63,25 @@ type testAccUserDataSourceConfig struct {
Username string
}
func (c testAccUserDataSourceConfig) String() string {
sb := strings.Builder{}
sb.WriteString(`data "coderd_user" "test" {` + "\n")
if c.ID != "" {
sb.WriteString(` id = "` + c.ID + `"` + "\n")
}
if c.Username != "" {
sb.WriteString(` username = "` + c.Username + `"` + "\n")
func (c testAccUserDataSourceConfig) String(t *testing.T) string {
tpl := `
data "coderd_user" "test" {
{{- if .ID }}
id = "{{ .ID }}"
{{- end }}
{{- if .Username }}
username = "{{ .Username }}"
{{- end }}
}`
tmpl := template.Must(template.New("userDataSource").Parse(tpl))
buf := strings.Builder{}
err := tmpl.Execute(&buf, c)
if err != nil {
panic(err)
}
sb.WriteString(`}`)
return sb.String()
return buf.String()
}
*/
3 changes: 0 additions & 3 deletions internal/provider/user_resource.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider

import (
Expand Down
3 changes: 0 additions & 3 deletions internal/provider/user_resource_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider

/*
Expand Down

0 comments on commit cc62729

Please sign in to comment.