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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
package main
import (
"context"
"slices"
"testing"
"mm/internal/config"
"mm/internal/detector"
"mm/internal/engine"
"github.com/firebase/genkit/go/genkit"
)
// assembledNames runs assembleTools on a fresh Genkit with only the built-in
// tools in play (no MCP gateway, no skills, no lsp).
func assembledNames(t *testing.T) []string {
t.Helper()
t.Setenv("MCP_GATEWAY_URL", "")
e := &engine.Engine{G: genkit.Init(context.Background())}
set := assembleTools(e, detector.NewLoopDetector(10, 3), nil)
return set.names
}
func withConfig(t *testing.T, change func(*config.Config)) {
t.Helper()
saved := config.Cfg
t.Cleanup(func() { config.Cfg = saved })
config.Cfg.SkillsDir = t.TempDir()
config.Cfg.MMConfigs = nil
config.Cfg.LSP.Servers = nil
config.Cfg.MCP.Enabled = false
change(&config.Cfg)
}
// ask_user is declared by default, not when askUserTool is off, and never
// beside a structuredOutput (which would refuse to start with a tool).
func TestAskUserIsDeclaredUnlessTurnedOffOrStructured(t *testing.T) {
cases := []struct {
name string
change func(*config.Config)
want bool
}{
{"default", func(*config.Config) {}, true},
{"askUserTool: false", func(c *config.Config) { c.AskUserTool = false }, false},
{"structuredOutput", func(c *config.Config) { c.OutputSchema = map[string]any{"type": "object"} }, false},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
withConfig(t, c.change)
if got := slices.Contains(assembledNames(t), "ask_user"); got != c.want {
t.Errorf("ask_user declared = %v, want %v", got, c.want)
}
})
}
}
|