Skip to content

Commit

Permalink
add test for index file being loades with posts func
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarchie committed Mar 31, 2023
1 parent 9ce8e61 commit 8acf44c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ tasks:
build: go build ./...
format: gofmt -w .
lint: golangci-lint run --fix --timeout "10m"
test: |
go test -cover -race ./...
go run ./... --source-path example/ --build-path ./build
test: go test -cover -race ./...
example: go run ./... --source-path example/ --build-path ./build
default:
cmds:
- task: format
- task: lint
- task: build
- task: test
- task: test
- task: example
3 changes: 3 additions & 0 deletions builder_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ var _ = Describe("Builder", func() {
)
}

createFile("posts/index.md", `# IGNORE ME`)

createFile("index.md", `
---
title: required
Expand All @@ -163,6 +165,7 @@ title: required
Expect(err).NotTo(HaveOccurred())

contents := readFile("index.html")
Expect(contents).ToNot(ContainSubstring(`IGNORE ME`))
Expect(contents).To(ContainSubstring(`<a href="/posts/10.html">some 10 title</a> 10`))
Expect(contents).To(ContainSubstring(`<a href="/posts/09.html">some 9 title</a>`))
Expect(contents).To(ContainSubstring(`<a href="/posts/08.html">some 8 title</a>`))
Expand Down
2 changes: 1 addition & 1 deletion docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewDocs(
}

matches = lo.Filter(matches, func(match string, _ int) bool {
return !strings.HasPrefix(match, "index.md")
return !strings.HasSuffix(match, "index.md")
})

sort.Strings(matches)
Expand Down
2 changes: 1 addition & 1 deletion view_doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (d *ViewDoc) Basename() string {

return strings.Replace(
basename,
".md",
".html",
"",
1,
)
Expand Down

0 comments on commit 8acf44c

Please sign in to comment.