6d07ca2be4
gates / gates (push) Successful in 1m3s
Unreleased; ships with tomorrow's release. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package agentapi
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// R-899: a household press tells the agent so (`trigger=manual`), and nothing else does — the agent runs the
|
|
// night's OS leg only after a backup that is not a press. The request the agent RECEIVES is asserted.
|
|
func TestR899_PressCarriesTriggerManual(t *testing.T) {
|
|
var got []string
|
|
mux := http.NewServeMux()
|
|
mux.HandleFunc("POST /backup", func(w http.ResponseWriter, r *http.Request) {
|
|
got = append(got, r.URL.RawQuery)
|
|
w.WriteHeader(http.StatusAccepted)
|
|
_, _ = w.Write([]byte(`{"ok":true,"data":{"vmid":9201,"job_id":"backup-9201-2","phase":"running"}}`))
|
|
})
|
|
s := httptest.NewTLSServer(mux)
|
|
defer s.Close()
|
|
c := clientFor(t, s, strings.TrimPrefix(s.URL, "https://"))
|
|
ctx := context.Background()
|
|
|
|
if _, err := c.StartBackup(ctx); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := c.StartBackupFor(ctx, "local"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := c.StartBackupForTrigger(ctx, "local", true); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := c.StartBackupForTrigger(ctx, "", true); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
want := []string{"", "target=local", "target=local&trigger=manual", "trigger=manual"}
|
|
if len(got) != len(want) {
|
|
t.Fatalf("queries = %q, want %q", got, want)
|
|
}
|
|
for i := range want {
|
|
if got[i] != want[i] {
|
|
t.Fatalf("query %d = %q, want %q (all: %q)", i, got[i], want[i], got)
|
|
}
|
|
}
|
|
}
|