turbo-editors/turbo-corepublic Fork 0
main
Commits
Clone
git clone https://git.rickub.com/turbo-editors/turbo-core.git
git clone ssh://git@rickub.com/turbo-editors/turbo-core.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

agent_files_test.go · 39 lines · 1.1 KBGo Blame HistoryRaw
🛟 Updated. 28d5985 k33g 5h ago1package app
2
3import (
4 "os"
5 "path/filepath"
6 "strings"
7 "testing"
8)
9
10func TestListProjectFilesSkipsGitAndStopsAtTheLimit(t *testing.T) {
11 root := t.TempDir()
12 for _, name := range []string{"main.go", "app/menus.go", ".git/HEAD", ".turbo-x/settings.toml", "docs/en/README.md"} {
13 path := filepath.Join(root, filepath.FromSlash(name))
14 if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
15 t.Fatal(err)
16 }
17 if err := os.WriteFile(path, []byte("x"), 0o644); err != nil {
18 t.Fatal(err)
19 }
20 }
21
22 files := listProjectFiles(root, 100)
23 var names []string
24 for _, file := range files {
25 names = append(names, file.Name)
26 if !filepath.IsAbs(file.Path) || !strings.HasPrefix(file.Path, root) {
27 t.Errorf("Path %q is not absolute under the project", file.Path)
28 }
29 }
30
31 want := ".turbo-x/settings.toml app/menus.go docs/en/README.md main.go"
32 if got := strings.Join(names, " "); got != want {
33 t.Errorf("listProjectFiles = %q, want %q: the editor's own directory in, .git out, slashes forward", got, want)
34 }
35
36 if got := listProjectFiles(root, 2); len(got) != 2 {
37 t.Errorf("a limit of 2 returned %d files", len(got))
38 }
39}