oficina / mapa Public

Clone
git clone https://amadan.net/oficina/mapa

Plain git — no account needed to clone.

Download

Download this file

1package mapatest
2
3import (
4 "net/http"
5 "net/url"
6 "strings"
7 "testing"
8)
9
10// L7 for the month calendar (review L): paging it with ?month= is a GET
11// and writes nothing, on a written day, an unwritten one and Today, with
12// a month, a month away and a value that is not a month. The row dump
13// is compared, not the file.
14func TestL7TheMonthCalendarWritesNothing(t *testing.T) {
15 rig := newRig(t)
16 rig.post(t, Ana, "/d/2026-11-10", url.Values{"body": {"Written."}})
17 before := dumpAll(t, rig)
18 for _, who := range []string{Ana, Bo} {
19 for _, day := range []string{"/d/2026-11-10", "/d/2026-11-20", "/"} {
20 for _, month := range []string{"2026-11", "2026-10",
21 "2027-01", "nonsense"} {
22 path := day + "?month=" + month
23 got := rig.fetchAs(who, path, nil)
24 if got.Code != http.StatusOK ||
25 !strings.Contains(got.Body.String(), "month=") {
26 t.Fatalf("%s GET %s: %d", who, path, got.Code)
27 }
28 }
29 }
30 }
31 if dumpAll(t, rig) != before {
32 t.Fatal("paging the month calendar wrote to the database")
33 }
34 rig.post(t, Ana, "/d/2026-11-20", url.Values{"body": {"Now written."}})
35 if dumpAll(t, rig) == before {
36 t.Fatal("the dump is vacuous: writing a day did not change it")
37 }
38}
39