setupTempConfig creates a temporary config file and overrides the default paths.
(t *testing.T)
| 12 | |
| 13 | // setupTempConfig creates a temporary config file and overrides the default paths. |
| 14 | func setupTempConfig(t *testing.T) func() { |
| 15 | t.Helper() |
| 16 | tmpDir := t.TempDir() |
| 17 | configPath := filepath.Join(tmpDir, "tryssh.db") |
| 18 | knownHostsPath := filepath.Join(tmpDir, "known_hosts") |
| 19 | |
| 20 | err := os.MkdirAll(tmpDir, 0755) |
| 21 | assert.NoError(t, err) |
| 22 | configData := []byte("main:\n ports: []\n users: []\n passwords: []\n keys: []\nserverList: []\n") |
| 23 | err = os.WriteFile(configPath, configData, 0600) |
| 24 | assert.NoError(t, err) |
| 25 | |
| 26 | origConfigPath := config.DefaultConfigPath |
| 27 | origKnownHostsPath := config.DefaultKnownHostsPath |
| 28 | config.DefaultConfigPath = configPath |
| 29 | config.DefaultKnownHostsPath = knownHostsPath |
| 30 | |
| 31 | return func() { |
| 32 | config.DefaultConfigPath = origConfigPath |
| 33 | config.DefaultKnownHostsPath = origKnownHostsPath |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | func TestNewSSHCommand_Structure(t *testing.T) { |
| 38 | cmd := NewSSHCommand() |
no outgoing calls
no test coverage detected