internal/httpd/footer_test.go

main
gitbay/internal/httpd/footer_test.go history · blame · raw

26 lines · 1001 bytes

1 symbol in this file
 1package httpd
 2
 3import (
 4	"strings"
 5	"testing"
 6)
 7
 8// The footer links the operator's terms and abuse pages only when
 9// configured, on a page with no viewer and on the 404 page.
10func TestFooterOperatorLinks(t *testing.T) {
11	s, _, _ := newTokenTestServer(t)
12	for _, path := range []string{"/privacy", "/no-such-owner"} {
13		if body := get(t, s.Handler(), path, nil).Body.String(); strings.Contains(body, "Report abuse") || strings.Contains(body, ">Terms<") {
14			t.Errorf("%s: footer links with nothing configured", path)
15		}
16	}
17	s.cfg.Web.AbuseURL = "https://example.test/wiki/Abuse"
18	s.cfg.Web.TermsURL = "https://example.test/wiki/Terms"
19	for _, path := range []string{"/privacy", "/no-such-owner"} {
20		body := get(t, s.Handler(), path, nil).Body.String()
21		if !strings.Contains(body, `<a href="https://example.test/wiki/Abuse">Report abuse</a>`) ||
22			!strings.Contains(body, `<a href="https://example.test/wiki/Terms">Terms</a>`) {
23			t.Errorf("%s: footer lacks the configured links", path)
24		}
25	}
26}