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) } } }