MCPcopy Create free account
hub / github.com/Driver-C/tryssh / setupTempConfig

Function setupTempConfig

cmd/ssh/ssh_test.go:14–35  ·  view source on GitHub ↗

setupTempConfig creates a temporary config file and overrides the default paths.

(t *testing.T)

Source from the content-addressed store, hash-verified

12
13// setupTempConfig creates a temporary config file and overrides the default paths.
14func 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
37func TestNewSSHCommand_Structure(t *testing.T) {
38 cmd := NewSSHCommand()

Calls

no outgoing calls

Tested by

no test coverage detected