Show the MIT licence in the page footers (closes #119)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
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
This commit was merged in pull request #144.
This commit is contained in:
@@ -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(), "<footer")
|
||||||
|
if !found {
|
||||||
|
t.Fatal("the page has no footer")
|
||||||
|
}
|
||||||
|
|
||||||
|
footer, _, _ = strings.Cut(footer, "</footer>")
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,8 +19,8 @@ const (
|
|||||||
Author = "@sneak"
|
Author = "@sneak"
|
||||||
// AuthorURL is the author's website
|
// AuthorURL is the author's website
|
||||||
AuthorURL = "https://sneak.berlin"
|
AuthorURL = "https://sneak.berlin"
|
||||||
// License is the program license
|
// License is the program license, as LICENSE grants it
|
||||||
License = "WTFPL"
|
License = "MIT"
|
||||||
// RepoURL is the git repository URL
|
// RepoURL is the git repository URL
|
||||||
RepoURL = "https://git.eeqj.de/sneak/routewatch"
|
RepoURL = "https://git.eeqj.de/sneak/routewatch"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user