Files
mesh-catalog/modules/mesh-mail-reader/cmd/mesh-mail-reader/tools_test.go
T
jschoubben 8c8b4367f1 mesh-mail-reader: its callers list goes; every verb answers every caller
Every account may call every verb; what protects the mail is what the verbs
answer (ADR 0459 §2), not who may call them.

Builds: design 47 H §764 (every callers list, §752); H-A-122

Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
2026-11-20 06:10:56 +01:00

54 lines
1.7 KiB
Go

package main
import (
"context"
"testing"
)
// 1426/AC3: the bundle's Tools() lists the six mail-reading verbs and mail_reader_health, each with its own
// argument schema.
func TestToolsListsTheSixVerbsAndHealth(t *testing.T) {
b := &Bundle{}
var names []string
for _, tool := range b.Tools() {
names = append(names, tool.Name)
if tool.Input == nil {
t.Errorf("%s has no argument schema", tool.Name)
}
if tool.Description == "" {
t.Errorf("%s has no description", tool.Name)
}
}
want := []string{
"mail-reading.entries", "mail-reading.groups", "mail-reading.correct", "mail-reading.lessons",
"mail-reading.undo", "mail-reading.status", "mail_reader_health",
}
if len(names) != len(want) {
t.Fatalf("Tools() = %v, want %v", names, want)
}
for i, n := range want {
if names[i] != n {
t.Fatalf("Tools()[%d] = %q, want %q", i, names[i], n)
}
}
}
// Design 47 H, H-A-122: a mail-reading verb answers every caller, even one the runtime proved nobody to be (the
// caller of arguments no call was handed): the module keeps no callers list.
func TestAMailReadingVerbAnswersEveryCaller(t *testing.T) {
b := &Bundle{Store: func(context.Context) (Store, error) { return newMemStore(), nil }}
for _, tool := range []struct {
name string
run func() (any, error)
}{
{EntriesTool, func() (any, error) { return b.entriesTool(map[string]any{}) }},
{GroupsTool, func() (any, error) { return b.groupsTool(map[string]any{}) }},
{LessonsTool, func() (any, error) { return b.lessonsTool(map[string]any{}) }},
{StatusTool, func() (any, error) { return b.statusTool(map[string]any{}) }},
} {
if _, err := tool.run(); err != nil {
t.Errorf("%s: %v, want an answer to any caller", tool.name, err)
}
}
}