3 Commits

Author SHA1 Message Date
Mathias Bergqvist
b493651c26 fix(test): update executor test fixture to match --output-format json envelope
All checks were successful
CI / Lint / Test / Vet (push) Successful in 1m9s
CI / Mirror to GitHub (push) Has been skipped
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 07:42:24 +02:00
Mathias Bergqvist
6169404f34 fix(lint): fix remaining errcheck in brain handlers_test
Some checks failed
CI / Lint / Test / Vet (push) Failing after 1m5s
CI / Mirror to GitHub (push) Has been skipped
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 07:17:45 +02:00
Mathias Bergqvist
a67106026f fix(lint): satisfy errcheck for io.Copy, json.Encode, Body.Close, deferred Close
Some checks failed
CI / Lint / Test / Vet (push) Failing after 3s
CI / Mirror to GitHub (push) Has been skipped
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 07:15:35 +02:00
5 changed files with 12 additions and 10 deletions

View File

@@ -47,9 +47,9 @@ func main() {
fmt.Fprintf(os.Stderr, "bridge: request failed: %v\n", err)
continue
}
io.Copy(os.Stdout, resp.Body)
resp.Body.Close()
os.Stdout.Write([]byte("\n"))
_, _ = io.Copy(os.Stdout, resp.Body)
_ = resp.Body.Close()
_, _ = os.Stdout.Write([]byte("\n"))
}
if err := scanner.Err(); err != nil {

View File

@@ -28,8 +28,10 @@ func fakeClaudePath(t *testing.T, output string, exitCode int) string {
}
func TestExecutorParsesValidResult(t *testing.T) {
validJSON := `{"status":"pass","phase":"red","skill":"tdd","file_path":"/tmp/x_test.go","runner_output":"FAIL","verified":true,"model_used":"self","message":"ok"}`
claude := fakeClaudePath(t, validJSON, 0)
// Fake claude emits the --output-format json envelope that the real CLI produces.
// The executor extracts the result from the "structured_output" field.
envelope := `{"type":"result","subtype":"success","is_error":false,"structured_output":{"status":"pass","phase":"red","skill":"tdd","file_path":"/tmp/x_test.go","runner_output":"FAIL","verified":true,"model_used":"self","message":"ok"}}`
claude := fakeClaudePath(t, envelope, 0)
ex := iexec.New(iexec.Config{
ClaudeBinary: claude,

View File

@@ -80,7 +80,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(response{
_ = json.NewEncoder(w).Encode(response{
JSONRPC: "2.0",
ID: req.ID,
Result: result,
@@ -90,7 +90,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func writeError(w http.ResponseWriter, id any, code int, msg string) {
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(response{
_ = json.NewEncoder(w).Encode(response{
JSONRPC: "2.0",
ID: id,
Error: &rpcError{Code: code, Message: msg},

View File

@@ -73,7 +73,7 @@ func Read(sessionsDir, sessionID string) ([]Entry, error) {
if err != nil {
return nil, fmt.Errorf("open session log: %w", err)
}
defer f.Close()
defer f.Close() //nolint:errcheck
var entries []Entry
scanner := bufio.NewScanner(f)

View File

@@ -18,7 +18,7 @@ func TestHandle_BrainQuery_CallsIngestServer(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, "/query", r.URL.Path)
called = true
json.NewEncoder(w).Encode(map[string]any{
_ = json.NewEncoder(w).Encode(map[string]any{
"results": []map[string]any{
{"path": "wiki/concepts/tdd.md", "title": "TDD", "excerpt": "Test-driven development.", "score": 3},
},
@@ -45,7 +45,7 @@ func TestHandle_BrainWrite_CallsIngestServer(t *testing.T) {
require.NoError(t, json.NewDecoder(r.Body).Decode(&body))
assert.Equal(t, "concept", body["type"])
assert.Equal(t, "# Test\n\nSome learning.", body["content"])
json.NewEncoder(w).Encode(map[string]string{"path": "raw/test.md"})
_ = json.NewEncoder(w).Encode(map[string]string{"path": "raw/test.md"})
}))
defer srv.Close()