Fold the seat verbs' test into the try tools test; pin the sdk head (issue 774)

This commit is contained in:
2026-10-27 23:01:18 +01:00
parent 7a86c62492
commit ac7bf01abf
3 changed files with 21 additions and 41 deletions
@@ -3,7 +3,6 @@ package main
import (
"encoding/json"
"errors"
"reflect"
"slices"
"strings"
"testing"
@@ -81,6 +80,24 @@ func TestTheTryToolsAskAndReadATry(t *testing.T) { // ADR 0501 §5, the agreed i
if err != nil || !strings.Contains(string(raw.(json.RawMessage)), `"state":"queued"`) {
t.Errorf("read = %s, %v", raw, err)
}
// The seat's verbs answer as the tools do (ADR 0547 §10, issue 774): the same ask is the same try, and the read is alike.
verbs := SeatTryTools(Trying{Tries: store, Ender: store, Now: func() time.Time { return time.Unix(1, 5) },
Trunks: func() (map[string]string, error) {
return map[string]string{"novox/mesh-delivery": strings.Repeat("a", 40)}, nil
}})
if len(verbs) != 3 || verbs[0].Name != Seat+".try" || verbs[1].Name != Seat+".try-read" || verbs[2].Name != Seat+".try-end" {
t.Fatalf("verbs = %+v", verbs)
}
again, err := verbs[0].Run(map[string]any{"repository": "novox/mesh-delivery", "head": strings.Repeat("1", 40), "trunk": "main"})
if err != nil || again.(map[string]any)["id"] != id {
t.Errorf("verb try = %v, %v, want the waiting try %s", again, err, id)
}
if viaVerb, err := verbs[1].Run(map[string]any{"id": id}); err != nil || string(viaVerb.(json.RawMessage)) != string(raw.(json.RawMessage)) {
t.Errorf("verb try-read = %s, %v; tool = %s", viaVerb, err, raw)
}
if _, err := verbs[0].Run(map[string]any{"repository": "novox/hq", "head": strings.Repeat("1", 40)}); err == nil {
t.Error("the verb tried a repository nothing checks")
}
// Issue 734: a try whose ask was lost is ended by hand with why, and its head is asked anew.
ended, err := tools[2].Run(map[string]any{"id": id, "why": "its ask was lost"})
if err != nil || ended.(map[string]any)["state"] != "error" {
@@ -94,40 +111,3 @@ func TestTheTryToolsAskAndReadATry(t *testing.T) { // ADR 0501 §5, the agreed i
t.Errorf("hq: %v", err)
}
}
// The seat's verbs answer as the tools do (ADR 0547 §10, issue 774): the same ask gives the same try, read and ended alike.
func TestTheSeatVerbsAnswerLikeTheTools(t *testing.T) {
store := &memStore{vals: map[string]json.RawMessage{}}
tr := Trying{Tries: store, Ender: store, Now: func() time.Time { return time.Unix(1, 5) },
Trunks: func() (map[string]string, error) {
return map[string]string{"novox/mesh-delivery": strings.Repeat("a", 40)}, nil
}}
tools, verbs := TryTools(tr), SeatTryTools(tr)
if len(verbs) != len(tools) {
t.Fatalf("%d verbs for %d tools", len(verbs), len(tools))
}
for i, want := range []string{"try", "try-read", "try-end"} {
if verbs[i].Name != Seat+"."+want {
t.Errorf("verb %d = %s", i, verbs[i].Name)
}
}
ask := map[string]any{"repository": "novox/mesh-delivery", "head": strings.Repeat("1", 40), "trunk": "main"}
a, err := tools[0].Run(ask)
if err != nil {
t.Fatal(err)
}
b, err := verbs[0].Run(ask) // a second ask of a head that waits is the first's answer
if err != nil || !reflect.DeepEqual(a, b) {
t.Errorf("verb try = %v, %v; tool = %v", b, err, a)
}
id := a.(map[string]any)["id"].(string)
ra, _ := tools[1].Run(map[string]any{"id": id})
rb, err := verbs[1].Run(map[string]any{"id": id})
if err != nil || !reflect.DeepEqual(ra, rb) {
t.Errorf("verb try-read = %v, %v; tool = %v", rb, err, ra)
}
if _, err := verbs[0].Run(map[string]any{"repository": "novox/hq", "head": strings.Repeat("1", 40)}); err == nil ||
err.Error() != "no level of novox/hq is checked by the checker" {
t.Errorf("hq: %v", err)
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ module mesh-delivery-checker
go 1.26.0
require (
git.novox.be/novox/mesh-sdk/go v0.1.14-0.20261027214944-9fdd33b03edc
git.novox.be/novox/mesh-sdk/go v0.1.14-0.20261027220038-a5d0e6420060
github.com/nats-io/nats-server/v2 v2.11.17
github.com/nats-io/nats.go v1.54.0
)
+2 -2
View File
@@ -1,5 +1,5 @@
git.novox.be/novox/mesh-sdk/go v0.1.14-0.20261027214944-9fdd33b03edc h1:3/wLzFyz4vJvt2TqDNGvLt7X9gF6JVBBPSS8l6+z6Zs=
git.novox.be/novox/mesh-sdk/go v0.1.14-0.20261027214944-9fdd33b03edc/go.mod h1:ouERNpZizzwZ0HLEtAypsY9FR20FyUgUYRni6J7kVCY=
git.novox.be/novox/mesh-sdk/go v0.1.14-0.20261027220038-a5d0e6420060 h1:DM3eFlsxGKObICNqWoT5TAdR28a6x2c0JjMeef4FRSc=
git.novox.be/novox/mesh-sdk/go v0.1.14-0.20261027220038-a5d0e6420060/go.mod h1:ouERNpZizzwZ0HLEtAypsY9FR20FyUgUYRni6J7kVCY=
github.com/antithesishq/antithesis-sdk-go v0.7.0-default-no-op h1:Z/MZK75wC/NSrkgqeNIa7jexam9uWzhLmFTSCPI/kn0=
github.com/antithesishq/antithesis-sdk-go v0.7.0-default-no-op/go.mod h1:FQyySiasQQM8735Ddel3MRojmy4dA1IqCeyJ5jmPMbI=
github.com/google/go-tpm v0.9.8 h1:slArAR9Ft+1ybZu0lBwpSmpwhRXaa85hWtMinMyRAWo=