1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package main
import (
"context"
"slices"
"testing"
"mm/internal/config"
"mm/internal/detector"
"mm/internal/engine"
"github.com/firebase/genkit/go/genkit"
)
// search_docs is declared only with docSearch.autoSearchDocs; searchDocs alone
// (the /docs command) does not declare it.
func TestSearchDocsIsDeclaredOnlyWhenAsked(t *testing.T) {
for _, c := range []struct {
name string
docs config.DocSearchConfig
want bool
}{
{"default", config.DocSearchConfig{}, false},
{"command only", config.DocSearchConfig{SearchDocs: true}, false},
{"tool", config.DocSearchConfig{AutoSearchDocs: true}, true},
} {
t.Run(c.name, func(t *testing.T) {
withConfig(t, func(cfg *config.Config) { cfg.DocSearch = c.docs })
t.Setenv("MCP_GATEWAY_URL", "")
set := assembleTools(&engine.Engine{G: genkit.Init(context.Background())}, detector.NewLoopDetector(10, 3), nil)
if got := slices.Contains(set.names, "search_docs"); got != c.want {
t.Errorf("search_docs declared = %v, want %v (names %v)", got, c.want, set.names)
}
})
}
}
|