MCPcopy Index your code
hub / github.com/coder/coder / runEditFiles

Function runEditFiles

agent/agentfiles/files_test.go:1776–1794  ·  view source on GitHub ↗

runEditFiles issues a single POST /edit-files call against api and decodes the success body into FileEditResponse. It requires a 200 response; tests for error paths should decode the error shape directly.

(t *testing.T, api *agentfiles.API, req workspacesdk.FileEditRequest)

Source from the content-addressed store, hash-verified

1774// response; tests for error paths should decode the error shape
1775// directly.
1776func runEditFiles(t *testing.T, api *agentfiles.API, req workspacesdk.FileEditRequest) workspacesdk.FileEditResponse {
1777 t.Helper()
1778
1779 ctx := testutil.Context(t, testutil.WaitShort)
1780
1781 buf := bytes.NewBuffer(nil)
1782 enc := json.NewEncoder(buf)
1783 enc.SetEscapeHTML(false)
1784 require.NoError(t, enc.Encode(req))
1785
1786 w := httptest.NewRecorder()
1787 r := httptest.NewRequestWithContext(ctx, http.MethodPost, "/edit-files", buf)
1788 api.Routes().ServeHTTP(w, r)
1789 require.Equal(t, http.StatusOK, w.Code, "body: %s", w.Body.String())
1790
1791 var resp workspacesdk.FileEditResponse
1792 require.NoError(t, json.NewDecoder(w.Body).Decode(&resp))
1793 return resp
1794}
1795
1796// TestFuzzyReplace_EndingAndWhitespace exercises the line-endings
1797// and per-position whitespace behavior of the fuzzy matcher in

Calls 7

ContextFunction · 0.92
EncodeMethod · 0.80
HelperMethod · 0.65
ServeHTTPMethod · 0.45
RoutesMethod · 0.45
EqualMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected