261101.6 · d81d8f77dde7b2f932e94d374c52339ffce44bfc
Tests follow the code they cover
server_test.go and web_test.go kept their tests when server.go and web.go split. Tests now sit in the test file of the code they drive, and the shared helpers stay in the two original files.
Declarations moved unchanged, as a sorted comparison of every line outside the import blocks confirms. git blame -C -C traces them.
reading declarations
Changes to about_test.go. All files
@@ -0,0 +1,26 @@+package main++import (+ "regexp"+ "strings"+ "testing"+)++// The build stamp shows only with --debug, and never on a share. It names+// the commit and the render time.+func TestBuildStamp(t *testing.T) {+ s, tr, _ := serveTree(t)+ defer func() { debugOn = false }()+ for _, c := range []struct{ show, shared, want bool }{+ {false, false, false}, {true, false, true}, {true, true, false},+ } {+ debugOn, tr.shared = c.show, c.shared+ body := get(s.handler(), "/a/").Body.String()+ if got := strings.Contains(body, `<p class="built" data-built="`); got != c.want {+ t.Errorf("stamp=%v shared=%v: shown=%v", c.show, c.shared, got)+ }+ if c.want && !regexp.MustCompile(`s ago, from [^<]+, rendered in [0-9.]+ ms</p>`).MatchString(body) {+ t.Errorf("stamp lacks commit or render time: %s", body)+ }+ }+}