返回 DeepSeek-Reasonix
slash_lazy_test.go
根目录 / internal / control / slash_lazy_test.go
1 package control
2
3 import (
4 "testing"
5
6 "reasonix/internal/skill"
7 )
8
9 func TestSlashArgItemsLazyResolvesOnlyDynamicStructuredCommands(t *testing.T) {
10 data := ArgData{Skills: []skill.Skill{{Name: "warm"}}}
11 calls := 0
12 resolve := func() ArgData {
13 calls++
14 return data
15 }
16
17 if items, _, applies := SlashArgItemsLazy("/custom free text", resolve); applies || len(items) != 0 {
18 t.Fatalf("free-form command unexpectedly applied: %+v", items)
19 }
20 if calls != 0 {
21 t.Fatalf("free-form command resolved dynamic data %d times", calls)
22 }
23
24 items, _, applies := SlashArgItemsLazy("/language e", resolve)
25 if !applies || len(items) != 1 || items[0].Label != "en" {
26 t.Fatalf("static structured completion = %+v, applies=%v", items, applies)
27 }
28 if calls != 0 {
29 t.Fatalf("static structured command resolved dynamic data %d times", calls)
30 }
31
32 items, _, applies = SlashArgItemsLazy("/skills show w", resolve)
33 if !applies || len(items) != 1 || items[0].Label != "warm" {
34 t.Fatalf("dynamic structured completion = %+v, applies=%v", items, applies)
35 }
36 if calls != 1 {
37 t.Fatalf("dynamic structured command resolved data %d times, want 1", calls)
38 }
39 }
40
40 lines GO