(t *testing.T)
| 13 | func ctxBg() context.Context { return context.Background() } |
| 14 | |
| 15 | func TestExtractFilePaths(t *testing.T) { |
| 16 | cases := []struct { |
| 17 | name string |
| 18 | in string |
| 19 | want []string |
| 20 | }{ |
| 21 | { |
| 22 | name: "bare path with slash", |
| 23 | in: "run go test on pkg/foo/bar_test.go please", |
| 24 | want: []string{"pkg/foo/bar_test.go"}, |
| 25 | }, |
| 26 | { |
| 27 | name: "basename with extension", |
| 28 | in: "look at main.go for the bug", |
| 29 | want: []string{"main.go"}, |
| 30 | }, |
| 31 | { |
| 32 | name: "@file command", |
| 33 | in: "@file src/index.ts please", |
| 34 | want: []string{"src/index.ts"}, |
| 35 | }, |
| 36 | { |
| 37 | name: "@path mention", |
| 38 | in: "check @src/components/Button.tsx", |
| 39 | want: []string{"src/components/Button.tsx"}, |
| 40 | }, |
| 41 | { |
| 42 | name: "multiple paths dedup", |
| 43 | in: "compare pkg/a.go and pkg/b.go and pkg/a.go again", |
| 44 | want: []string{"pkg/a.go", "pkg/b.go"}, |
| 45 | }, |
| 46 | { |
| 47 | name: "no paths", |
| 48 | in: "hello world how are you today", |
| 49 | want: nil, |
| 50 | }, |
| 51 | { |
| 52 | name: "trims surrounding punctuation", |
| 53 | in: "the file (src/x.ts) was changed.", |
| 54 | want: []string{"src/x.ts"}, |
| 55 | }, |
| 56 | } |
| 57 | for _, tc := range cases { |
| 58 | t.Run(tc.name, func(t *testing.T) { |
| 59 | got := extractFilePaths(tc.in) |
| 60 | sort.Strings(got) |
| 61 | want := append([]string(nil), tc.want...) |
| 62 | sort.Strings(want) |
| 63 | if !reflect.DeepEqual(got, want) { |
| 64 | t.Fatalf("extractFilePaths(%q)\n got: %v\nwant: %v", tc.in, got, want) |
| 65 | } |
| 66 | }) |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | func TestBuildSkillInjectionBlock(t *testing.T) { |
| 71 | if buildSkillInjectionBlock(nil) != "" { |
nothing calls this directly
no test coverage detected