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

Function TestCreateWithPreset

cli/create_test.go:1182–1816  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1180}
1181
1182func TestCreateWithPreset(t *testing.T) {
1183 t.Parallel()
1184
1185 const (
1186 firstParameterName = "first_parameter"
1187 firstParameterDisplayName = "First Parameter"
1188 firstParameterDescription = "This is the first parameter"
1189 firstParameterValue = "1"
1190
1191 firstOptionalParameterName = "first_optional_parameter"
1192 firstOptionalParameterDescription = "This is the first optional parameter"
1193 firstOptionalParameterValue = "1"
1194 secondOptionalParameterName = "second_optional_parameter"
1195 secondOptionalParameterDescription = "This is the second optional parameter"
1196 secondOptionalParameterValue = "2"
1197
1198 thirdParameterName = "third_parameter"
1199 thirdParameterDescription = "This is the third parameter"
1200 thirdParameterValue = "3"
1201 )
1202
1203 echoResponses := func(presets ...*proto.Preset) *echo.Responses {
1204 return prepareEchoResponses([]*proto.RichParameter{
1205 {
1206 Name: firstParameterName,
1207 DisplayName: firstParameterDisplayName,
1208 Description: firstParameterDescription,
1209 Mutable: true,
1210 DefaultValue: firstParameterValue,
1211 Options: []*proto.RichParameterOption{
1212 {
1213 Name: firstOptionalParameterName,
1214 Description: firstOptionalParameterDescription,
1215 Value: firstOptionalParameterValue,
1216 },
1217 {
1218 Name: secondOptionalParameterName,
1219 Description: secondOptionalParameterDescription,
1220 Value: secondOptionalParameterValue,
1221 },
1222 },
1223 },
1224 {
1225 Name: thirdParameterName,
1226 Description: thirdParameterDescription,
1227 DefaultValue: thirdParameterValue,
1228 Mutable: true,
1229 },
1230 }, presets...)
1231 }
1232
1233 // This test verifies that when a template has presets,
1234 // including a default preset, and the user specifies a `--preset` flag,
1235 // the CLI uses the specified preset instead of the default
1236 t.Run("PresetFlag", func(t *testing.T) {
1237 t.Parallel()
1238
1239 client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})

Callers

nothing calls this directly

Calls 15

NewFunction · 0.92
CreateFirstUserFunction · 0.92
CreateAnotherUserFunction · 0.92
CreateTemplateVersionFunction · 0.92
CreateTemplateFunction · 0.92
NewFunction · 0.92
SetupConfigFunction · 0.92
NewFunction · 0.92
WorkspacesMethod · 0.80

Tested by

no test coverage detected