From e13240cb04083b8b34de1b5e92ab0b69e3fc4622 Mon Sep 17 00:00:00 2001 From: clawbot <35+clawbot@noreply.example.org> Date: Tue, 20 Oct 2026 03:46:44 +0200 Subject: [PATCH] Show the MIT licence in the page footers (closes #119) version.License, which the home and status page footers show, still said WTFPL after LICENSE and the README moved to MIT. It now says MIT. A test renders both pages and expects each footer to name MIT and not WTFPL. Model: opus-5-5 --- internal/templates/templates_test.go | 54 ++++++++++++++++++++++++++++ internal/version/version.go | 4 +-- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 internal/templates/templates_test.go diff --git a/internal/templates/templates_test.go b/internal/templates/templates_test.go new file mode 100644 index 0000000..da1dd1c --- /dev/null +++ b/internal/templates/templates_test.go @@ -0,0 +1,54 @@ +package templates_test + +import ( + "bytes" + "html/template" + "strings" + "testing" + + "git.eeqj.de/sneak/routewatch/internal/templates" +) + +// TestFooterLicense renders the home and status pages and expects each footer +// to name the licence in LICENSE, MIT, and not WTFPL. +func TestFooterLicense(t *testing.T) { + t.Parallel() + + const ( + license = "MIT" + wrongLicense = "WTFPL" + ) + + pages := map[string]*template.Template{ + "index": templates.IndexTemplate(), + "status": templates.StatusTemplate(), + } + + for name, tmpl := range pages { + t.Run(name, func(t *testing.T) { + t.Parallel() + + var page bytes.Buffer + + err := tmpl.Execute(&page, struct{ CSPNonce string }{}) + if err != nil { + t.Fatalf("rendering the page: %v", err) + } + + _, footer, found := strings.Cut(page.String(), "") + + if !strings.Contains(footer, license) { + t.Errorf("footer does not name %s: %q", license, footer) + } + + if strings.Contains(footer, wrongLicense) { + t.Errorf("footer names %s: %q", wrongLicense, footer) + } + }) + } +} diff --git a/internal/version/version.go b/internal/version/version.go index 20c44d5..abf6787 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -19,8 +19,8 @@ const ( Author = "@sneak" // AuthorURL is the author's website AuthorURL = "https://sneak.berlin" - // License is the program license - License = "WTFPL" + // License is the program license, as LICENSE grants it + License = "MIT" // RepoURL is the git repository URL RepoURL = "https://git.eeqj.de/sneak/routewatch" )