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

Function TestConfigSSH_FileWriteAndOptionsFlow

cli/configssh_test.go:271–812  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

269}
270
271func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
272 t.Parallel()
273
274 headerStart := strings.Join([]string{
275 "# ------------START-CODER-----------",
276 "# This section is managed by coder. DO NOT EDIT.",
277 "#",
278 "# You should not hand-edit this section unless you are removing it, all",
279 "# changes will be lost when running \"coder config-ssh\".",
280 "#",
281 }, "\n")
282 headerEnd := "# ------------END-CODER------------"
283 baseHeader := strings.Join([]string{
284 headerStart,
285 headerEnd,
286 }, "\n")
287
288 type writeConfig struct {
289 ssh string
290 }
291 type wantConfig struct {
292 ssh []string
293 regexMatch string
294 }
295 type match struct {
296 match, write string
297 }
298 tests := []struct {
299 name string
300 args []string
301 matches []match
302 writeConfig writeConfig
303 wantConfig wantConfig
304 wantErr bool
305 hasAgent bool
306 }{
307 {
308 name: "Config file is created",
309 matches: []match{
310 {match: "Continue?", write: "yes"},
311 },
312 wantConfig: wantConfig{
313 ssh: []string{
314 headerStart,
315 headerEnd,
316 },
317 },
318 },
319 {
320 name: "Section is written after user content",
321 writeConfig: writeConfig{
322 ssh: strings.Join([]string{
323 "Host myhost",
324 " HostName myhost",
325 }, "\n"),
326 },
327 wantConfig: wantConfig{
328 ssh: []string{

Callers

nothing calls this directly

Calls 15

NewWithDatabaseFunction · 0.92
CreateFirstUserFunction · 0.92
WorkspaceBuildFunction · 0.92
NewFunction · 0.92
SetupConfigFunction · 0.92
NewFunction · 0.92
sshConfigFileNameFunction · 0.85
sshConfigFileCreateFunction · 0.85
tGoFunction · 0.85
sshConfigFileReadFunction · 0.85
WithAgentMethod · 0.80
WriteLineMethod · 0.80

Tested by

no test coverage detected