@ 261101.7 · fetching

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 webpage_test.go. All files

webpage_test.go

new file mode 100644@@ -0,0 +1,18 @@+package main++import (+	"strings"+	"testing"+)++// The web address's index links back to the trees on the default address.+func TestWebLinksHome(t *testing.T) {+	w := testWeb(t, defaultDisk)+	if strings.Contains(webGet(w, "/").Body.String(), "Trees:") {+		t.Errorf("a link home without a home")+	}+	w.srv.homeURL = "http://127.31.1.1:8080"+	if body := webGet(w, "/").Body.String(); !strings.Contains(body, `Trees: <a href="http://127.31.1.1:8080/">127.31.1.1:8080/</a>`) {+		t.Errorf("no link home: %s", body)+	}+}