Fakehome tests: fail on transport faults; restore Memoria comment
The driver's post now fails on transport and read errors, and send treats only 403 as a refusal, so negative assertions cannot pass on a server fault. The Memoria comment returns to sit above its test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+16
−7
homeop/fakehome/fakehome_test.go+13 −4provision/apps_test.go+3 −3
diff --git a/homeop/fakehome/fakehome_test.go b/homeop/fakehome/fakehome_test.go| index 6d44d38..cd21583 100644 |
| --- a/homeop/fakehome/fakehome_test.go |
| +++ b/homeop/fakehome/fakehome_test.go |
| @@ -56,10 +56,13 @@ func (d *driver) post(role, path string, body []byte) (int, []byte) { |
| req.Header.Set("Authorization", "Bearer "+d.pre) |
| resp, err := http.DefaultClient.Do(req) |
| if err != nil { |
| - return 0, nil |
| + d.t.Fatalf("transport error: %v", err) |
| } |
| defer resp.Body.Close() |
| - out, _ := io.ReadAll(resp.Body) |
| + out, err := io.ReadAll(resp.Body) |
| + if err != nil { |
| + d.t.Fatalf("reading the answer: %v", err) |
| + } |
| return resp.StatusCode, out |
| } |
| @@ -101,12 +104,18 @@ func (d *driver) sign(role, action string, input func(homeop.InputBase) any) hom |
| return req |
| } |
| -// send posts req; a committed operation advances the stream. |
| +// send posts req; a committed operation advances the stream. ok is false |
| +// only for Home's explicit refusal (403); any other status fails the test, |
| +// so a negative assertion cannot pass on a server fault. |
| func (d *driver) send(role string, req homeop.Request) (homeop.Result, bool) { |
| d.t.Helper() |
| status, body := d.post(role, "/operator/v1", req.Bytes) |
| - if status != 200 { |
| + switch status { |
| + case 200: |
| + case 403: |
| return homeop.Result{}, false |
| + default: |
| + d.t.Fatalf("operation answered %d, want 200 or 403", status) |
| } |
| var res homeop.Result |
| if err := homeop.Decode(body, &res); err != nil { |
diff --git a/provision/apps_test.go b/provision/apps_test.go| index 6928390..9417cd1 100644 |
| --- a/provision/apps_test.go |
| +++ b/provision/apps_test.go |
| @@ -60,9 +60,6 @@ func TestRosterRecipes(t *testing.T) { |
| } |
| } |
| -// Memoria in team mode: MEMORIA_TEAM must be the first label of |
| -// MEMORIA_ORIGIN (team_siblings.go refuses boot otherwise), and AI stays |
| -// off: no MEMORIA_AI, TensorX key, siblings or logged mail, ever. |
| // The adoption label answers Home's canonical tuple, from Alta's own |
| // helpers; every other label keeps the label.app shape. |
| func TestCanonicalHelpersForOficina(t *testing.T) { |
| @@ -113,6 +110,9 @@ func TestTeamKeyNamesMatchesRecipe(t *testing.T) { |
| } |
| } |
| +// Memoria in team mode: MEMORIA_TEAM must be the first label of |
| +// MEMORIA_ORIGIN (team_siblings.go refuses boot otherwise), and AI stays |
| +// off: no MEMORIA_AI, TensorX key, siblings or logged mail, ever. |
| func TestMemoriaTeamLabelAndAIOff(t *testing.T) { |
| app, _ := AppBySlug("memoria") |
| vals := map[string]string{} |