MCPcopy Create free account
hub / github.com/compozy/agh / TestUnixSocketClientRepairSession

Function TestUnixSocketClientRepairSession

internal/cli/client_test.go:1788–1830  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1786}
1787
1788func TestUnixSocketClientRepairSession(t *testing.T) {
1789 t.Parallel()
1790
1791 t.Run("Should repair session with dry run and force", func(t *testing.T) {
1792 t.Parallel()
1793
1794 client := &unixSocketClient{
1795 socketPath: "/tmp/agh.sock",
1796 httpClient: &http.Client{
1797 Transport: roundTripperFunc(func(req *http.Request) (*http.Response, error) {
1798 if req.Method == http.MethodGet && req.URL.Path == "/api/sessions" {
1799 return newHTTPResponse(
1800 http.StatusOK,
1801 `{"sessions":[{"id":"sess-1","agent_name":"coder","workspace_id":"ws-1","workspace_path":"/tmp","state":"stopped","created_at":"2026-04-03T12:00:00Z","updated_at":"2026-04-03T12:00:00Z"}]}`,
1802 ), nil
1803 }
1804 if req.Method != http.MethodPost || req.URL.Path != "/api/workspaces/ws-1/sessions/sess-1/repair" {
1805 return newHTTPResponse(http.StatusNotFound, `{"error":"missing"}`), nil
1806 }
1807 if got := req.URL.Query().Get("dry_run"); got != "true" {
1808 t.Fatalf("repair dry_run query = %q, want true", got)
1809 }
1810 if got := req.URL.Query().Get("force"); got != "true" {
1811 t.Fatalf("repair force query = %q, want true", got)
1812 }
1813 return newHTTPResponse(
1814 http.StatusOK,
1815 `{"repair":{"session_id":"sess-1","persisted":false,"issues":[],"actions":[{"code":"append_terminal_error","turn_id":"turn-1","persisted":false}]}}`,
1816 ), nil
1817 }),
1818 },
1819 }
1820
1821 repaired, err := client.RepairSession(
1822 context.Background(),
1823 "sess-1",
1824 SessionRepairQuery{DryRun: true, Force: true},
1825 )
1826 if err != nil || repaired.SessionID != "sess-1" || len(repaired.Actions) != 1 {
1827 t.Fatalf("RepairSession() = %#v, %v", repaired, err)
1828 }
1829 })
1830}
1831
1832func TestUnixSocketClientSkillMarketplaceMethods(t *testing.T) {
1833 t.Parallel()

Callers

nothing calls this directly

Calls 6

RepairSessionMethod · 0.95
roundTripperFuncFuncType · 0.85
newHTTPResponseFunction · 0.70
RunMethod · 0.65
GetMethod · 0.65
QueryMethod · 0.65

Tested by

no test coverage detected