| 86 | } |
| 87 | |
| 88 | func TestRunOverwritesExistingConfigWithForce(t *testing.T) { |
| 89 | targetPath := filepath.Join(t.TempDir(), "config.yml") |
| 90 | require.NoError(t, os.WriteFile(targetPath, []byte("existing"), 0600)) |
| 91 | |
| 92 | _, err := Run(Options{ |
| 93 | Force: true, |
| 94 | TargetPath: targetPath, |
| 95 | Prompts: &fakePrompts{ |
| 96 | lines: []string{"user@example.com", "", ""}, |
| 97 | password: "secret", |
| 98 | }, |
| 99 | }) |
| 100 | require.NoError(t, err) |
| 101 | |
| 102 | bs, readErr := os.ReadFile(targetPath) |
| 103 | require.NoError(t, readErr) |
| 104 | assert.Contains(t, string(bs), "username: user@example.com") |
| 105 | assert.NotEqual(t, "existing", string(bs)) |
| 106 | } |
| 107 | |
| 108 | func TestRunRequiresUsername(t *testing.T) { |
| 109 | targetPath := filepath.Join(t.TempDir(), "config.yml") |