feat: support folder index pages
This commit is contained in:
39
apps/server/internal/docs/service_test.go
Normal file
39
apps/server/internal/docs/service_test.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package docs
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNormalizeRequestPathCandidatesSupportsIndexFiles(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
path string
|
||||
want []string
|
||||
}{
|
||||
{
|
||||
name: "root",
|
||||
path: "",
|
||||
want: []string{"index.md", "getting-started.md"},
|
||||
},
|
||||
{
|
||||
name: "clean folder or page path",
|
||||
path: "guide",
|
||||
want: []string{"guide.md", "guide/index.md"},
|
||||
},
|
||||
{
|
||||
name: "explicit markdown path",
|
||||
path: "guide/index.md",
|
||||
want: []string{"guide/index.md"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := normalizeRequestPathCandidates(tt.path)
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
t.Fatalf("normalizeRequestPathCandidates(%q) = %#v, want %#v", tt.path, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user