MCPcopy Index your code
hub / github.com/larksuite/cli / TestListPath

Function TestListPath

internal/skillcontent/reader_test.go:64–146  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62}
63
64func TestListPath(t *testing.T) {
65 r := New(testFS())
66
67 // Skill root: direct children only (one layer), each path skill-prefixed.
68 entries, listed, err := r.ListPath("lark-calendar")
69 if err != nil {
70 t.Fatalf("ListPath root error: %v", err)
71 }
72 if listed != "lark-calendar" {
73 t.Errorf("listed path: got %q", listed)
74 }
75 want := map[string]bool{ // path → isDir
76 "lark-calendar/SKILL.md": false,
77 "lark-calendar/references": true,
78 "lark-calendar/assets": true,
79 }
80 if len(entries) != len(want) {
81 t.Fatalf("root entries: got %v, want %d entries", entries, len(want))
82 }
83 for _, e := range entries {
84 isDir, ok := want[e.Path]
85 if !ok {
86 t.Errorf("unexpected entry %q", e.Path)
87 continue
88 }
89 if e.IsDir != isDir {
90 t.Errorf("%q is_dir: got %v, want %v", e.Path, e.IsDir, isDir)
91 }
92 }
93 // Entries are sorted by path.
94 if entries[0].Path != "lark-calendar/SKILL.md" {
95 t.Errorf("entries not sorted: %v", entries)
96 }
97
98 // Subdirectory: one layer under <name>/<subpath>.
99 subEntries, subListed, err := r.ListPath("lark-calendar/references")
100 if err != nil {
101 t.Fatalf("ListPath subdir error: %v", err)
102 }
103 if subListed != "lark-calendar/references" {
104 t.Errorf("listed subpath: got %q", subListed)
105 }
106 if len(subEntries) != 2 ||
107 subEntries[0].Path != "lark-calendar/references/agenda.md" ||
108 subEntries[1].Path != "lark-calendar/references/create.md" {
109 t.Errorf("subdir entries: got %v", subEntries)
110 }
111
112 // Unknown skill → typed validation error.
113 if _, _, err := r.ListPath("no-such-skill"); err == nil {
114 t.Error("expected error for unknown skill")
115 } else {
116 var verr *errs.ValidationError
117 if !errors.As(err, &verr) {
118 t.Errorf("expected *errs.ValidationError, got %T", err)
119 }
120 }
121

Callers

nothing calls this directly

Calls 6

testFSFunction · 0.85
ListPathMethod · 0.80
AsMethod · 0.80
NewFunction · 0.70
ErrorMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected