test(agents): fix unchecked test helper results

Explicitly discard errors stored by GORM and response write results in
mock handlers to satisfy errcheck.

Assisted-by: Codex:gpt-6
This commit is contained in:
localai-org-maint-bot committed 2026-09-20 03:02:53 +00:00
1 parent fe3eed81c4
commit e92243ad12
2 files changed
+5 -5

No files matched your search

@@ -23,18 +23,18 @@ var _ = Describe("knowledge-base models authorization", func() {
switch row := tx.Statement.Dest.(type) {
case *auth.User:
if failUser {
tx.AddError(fmt.Errorf("user lookup unavailable"))
_ = tx.AddError(fmt.Errorf("user lookup unavailable"))
return
}
*row = auth.User{ID: "alice", Role: role}
case *auth.UserPermission:
if failPermissions {
tx.AddError(fmt.Errorf("permissions unavailable"))
_ = tx.AddError(fmt.Errorf("permissions unavailable"))
return
}
*row = auth.UserPermission{UserID: "alice", AllowedModels: auth.ModelAllowlist{Enabled: true, Models: []string{"allowed"}}}
default:
tx.AddError(fmt.Errorf("unexpected query destination %T", row))
_ = tx.AddError(fmt.Errorf("unexpected query destination %T", row))
}
})).To(Succeed())
cfg := &state.AgentConfig{Name: "Research", EmbeddingModel: "denied"}
@@ -89,11 +89,11 @@ var _ = Describe("knowledge-base models", func() {
w.Header().Set("Content-Type", "application/json")
if strings.HasSuffix(r.URL.Path, "/rerank") {
rerankers = append(rerankers, body.Model)
w.Write([]byte(`{"results":[{"index":0,"relevance_score":0.9}]}`))
_, _ = w.Write([]byte(`{"results":[{"index":0,"relevance_score":0.9}]}`))
return
}
embeddings = append(embeddings, body.Model)
w.Write([]byte(`{"data":[{"embedding":[1,0,0],"index":0}],"model":"test","usage":{}}`))
_, _ = w.Write([]byte(`{"data":[{"embedding":[1,0,0],"index":0}],"model":"test","usage":{}}`))
}))
DeferCleanup(server.Close)
svc.appConfig.AgentPool.APIURL = server.URL + "/v1"