File view with blame information shown in the left gutter beside each line.

barerepo / server / internal/httpd/booktalk_test.go
30 lines · 878b · 133728eaa05486504991b230f9d4c7e986b7defc
log files threads runs releases config jump to file t
133728e barerepo 1mo
1
package httpd
133728e barerepo 1mo
2
133728e barerepo 1mo
3
import (
133728e barerepo 1mo
4
"io/fs"
133728e barerepo 1mo
5
"regexp"
133728e barerepo 1mo
6
"strings"
133728e barerepo 1mo
7
"testing"
133728e barerepo 1mo
8
)
133728e barerepo 1mo
9
133728e barerepo 1mo
10
// A reader has no copy of the book, so nothing that cites it belongs on a page they can open.
133728e barerepo 1mo
11
var bookTalk = regexp.MustCompile(`(?i)\b(chapter|appendix|rule) \d|BOOK\.md|BUILD\.md|SPEC-NOTES`)
133728e barerepo 1mo
12
133728e barerepo 1mo
13
func TestNoPageTalksToWhoeverWroteIt(t *testing.T) {
133728e barerepo 1mo
14
names, err := fs.Glob(templateFS, "templates/*.html")
133728e barerepo 1mo
15
if err != nil || len(names) == 0 {
133728e barerepo 1mo
16
t.Fatalf("found no templates to read: %v", err)
133728e barerepo 1mo
17
}
133728e barerepo 1mo
18
for _, name := range names {
133728e barerepo 1mo
19
body, err := fs.ReadFile(templateFS, name)
133728e barerepo 1mo
20
if err != nil {
133728e barerepo 1mo
21
t.Fatal(err)
133728e barerepo 1mo
22
}
133728e barerepo 1mo
23
for i, line := range strings.Split(string(body), "\n") {
133728e barerepo 1mo
24
// A go comment is for whoever writes barerepo, and a template has no comments to skip.
133728e barerepo 1mo
25
if found := bookTalk.FindString(line); found != "" {
133728e barerepo 1mo
26
t.Errorf("%s:%d shows a reader %q, and a reader has no book", name, i+1, found)
133728e barerepo 1mo
27
}
133728e barerepo 1mo
28
}
133728e barerepo 1mo
29
}
133728e barerepo 1mo
30
}
history · rawbarerepo 0.1.0