CreateTestConfigFile writes a test configuration file in the given directory.
(t *testing.T, dir string, content string)
| 16 | |
| 17 | // CreateTestConfigFile writes a test configuration file in the given directory. |
| 18 | func CreateTestConfigFile(t *testing.T, dir string, content string) string { |
| 19 | t.Helper() |
| 20 | path := filepath.Join(dir, "tryssh.db") |
| 21 | if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { |
| 22 | t.Fatalf("Failed to create config dir: %v", err) |
| 23 | } |
| 24 | if err := os.WriteFile(path, []byte(content), 0644); err != nil { |
| 25 | t.Fatalf("Failed to write test config: %v", err) |
| 26 | } |
| 27 | return path |
| 28 | } |
| 29 | |
| 30 | // CreateTestKnownHosts writes a test known_hosts file in the given directory. |
| 31 | func CreateTestKnownHosts(t *testing.T, dir string, content string) string { |
no outgoing calls