MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / TestRemoveSSHHostEntryNonExistent

Function TestRemoveSSHHostEntryNonExistent

cmd/delete_test.go:155–177  ·  view source on GitHub ↗

TestRemoveSSHHostEntryNonExistent verifies that the removeSSHHostEntry function handles non-existent entries gracefully without errors.

(t *testing.T)

Source from the content-addressed store, hash-verified

153// TestRemoveSSHHostEntryNonExistent verifies that the removeSSHHostEntry function
154// handles non-existent entries gracefully without errors.
155func TestRemoveSSHHostEntryNonExistent(t *testing.T) {
156 env := testutils.SetupTestEnvironment(t)
157 defer env.Cleanup()
158
159 sshDir := filepath.Join(env.TempDir, ".ssh")
160 require.NoError(t, os.MkdirAll(sshDir, 0700))
161
162 sshConfigPath := filepath.Join(sshDir, "config")
163 sshConfig := `Host tnr-existing
164 HostName 192.168.1.100
165 User ubuntu
166`
167 require.NoError(t, os.WriteFile(sshConfigPath, []byte(sshConfig), 0600))
168
169 err := removeSSHHostEntry(sshConfigPath, "nonexistent")
170 require.NoError(t, err)
171
172 configData, err := os.ReadFile(sshConfigPath)
173 require.NoError(t, err)
174
175 configContent := string(configData)
176 assert.Contains(t, configContent, "tnr-existing")
177}
178
179// TestDeleteInstanceResponse verifies that the delete instance response
180// structure contains the expected fields and values.

Callers

nothing calls this directly

Calls 5

SetupTestEnvironmentFunction · 0.92
removeSSHHostEntryFunction · 0.85
MkdirAllMethod · 0.65
WriteFileMethod · 0.65
ReadFileMethod · 0.65

Tested by

no test coverage detected