File tree 2 files changed +11
-12
lines changed 2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ resource "coderd_group" "test" {
131
131
}
132
132
133
133
buf := strings.Builder {}
134
- tmpl , err := template .New ("test " ).Funcs (funcMap ).Parse (tpl )
134
+ tmpl , err := template .New ("groupResource " ).Funcs (funcMap ).Parse (tpl )
135
135
require .NoError (t , err )
136
136
137
137
err = tmpl .Execute (& buf , c )
Original file line number Diff line number Diff line change @@ -120,28 +120,27 @@ type testAccUserDataSourceConfig struct {
120
120
}
121
121
122
122
func (c testAccUserDataSourceConfig ) String (t * testing.T ) string {
123
+ t .Helper ()
123
124
tpl := `
124
125
provider coderd {
125
126
url = "{{.URL}}"
126
127
token = "{{.Token}}"
127
128
}
128
129
129
130
data "coderd_user" "test" {
130
- {{- if .ID }}
131
- id = "{{ .ID }}"
132
- {{- end }}
133
- {{- if .Username }}
134
- username = "{{ .Username }}"
135
- {{- end }}
131
+ id = {{orNull .ID}}
132
+ username = {{orNull .Username}}
136
133
}`
137
134
138
- tmpl := template .Must (template .New ("userDataSource" ).Parse (tpl ))
135
+ funcMap := template.FuncMap {
136
+ "orNull" : PrintOrNull (t ),
137
+ }
139
138
140
139
buf := strings.Builder {}
141
- err := tmpl .Execute (& buf , c )
142
- if err != nil {
143
- panic (err )
144
- }
140
+ tmpl , err := template .New ("userDataSource" ).Funcs (funcMap ).Parse (tpl )
141
+ require .NoError (t , err )
145
142
143
+ err = tmpl .Execute (& buf , c )
144
+ require .NoError (t , err )
146
145
return buf .String ()
147
146
}
You can’t perform that action at this time.
0 commit comments