MCPcopy Index your code
hub / github.com/coder/coder / TestTemplateVersionParameter_OK

Function TestTemplateVersionParameter_OK

coderd/database/db2sdk/db2sdk_test.go:153–181  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

151}
152
153func TestTemplateVersionParameter_OK(t *testing.T) {
154 t.Parallel()
155 req := require.New(t)
156
157 // In this test we're just going to cover the fields that have to get parsed.
158 options := []*proto.RichParameterOption{
159 {
160 Name: "foo",
161 Description: "bar",
162 Value: "baz",
163 Icon: "David Bowie",
164 },
165 }
166 ob, err := json.Marshal(&options)
167 req.NoError(err)
168
169 db := database.TemplateVersionParameter{
170 Options: json.RawMessage(ob),
171 Description: "_The Rise and Fall of **Ziggy Stardust** and the Spiders from Mars_",
172 }
173 sdk, err := db2sdk.TemplateVersionParameter(db)
174 req.NoError(err)
175 req.Len(sdk.Options, 1)
176 req.Equal("foo", sdk.Options[0].Name)
177 req.Equal("bar", sdk.Options[0].Description)
178 req.Equal("baz", sdk.Options[0].Value)
179 req.Equal("David Bowie", sdk.Options[0].Icon)
180 req.Equal("The Rise and Fall of Ziggy Stardust and the Spiders from Mars", sdk.DescriptionPlaintext)
181}
182
183func TestTemplateVersionParameter_BadOptions(t *testing.T) {
184 t.Parallel()

Callers

nothing calls this directly

Calls 5

TemplateVersionParameterFunction · 0.92
NewMethod · 0.65
MarshalMethod · 0.45
LenMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected