commit ce899374b82bd14f6a232811792ae55585a313f5 equwal <13551856+equwal@users.noreply.github.com> 2026-09-25 02:51:32 -0700 Test that the admin page shows the feed of each link The test renders the admin page with a link that has a feed and a link without one.
server_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
diff --git a/server_test.go b/server_test.go index 045df11..d3769a1 100644 --- a/server_test.go +++ b/server_test.go @@ -132,6 +132,22 @@ func TestAddGivesTheFeedToALinkWithout(t *testing.T) { } } +func TestAdminPageShowsFeeds(t *testing.T) { + s, h := newServer(t) + write(t, s, "https://github.com/a/b\tB\tx\thttps://github.com/a/b/releases.atom\nhttps://c.com\tC\t\n") + body := do(h, httptest.NewRequest("GET", "/links/admin", nil), true).Body.String() + for _, want := range []string{ + `<input type="url" name="feed" placeholder="Feed (RSS or Atom) of the site, if it has one">`, + `<span class="host">github.com/a/b</span>`, + `<input type="url" name="feed" value="https://github.com/a/b/releases.atom" placeholder="Feed (RSS or Atom)">`, + `<input type="url" name="feed" value="" placeholder="Feed (RSS or Atom)">`, + } { + if !strings.Contains(body, want) { + t.Errorf("admin page has no %s", want) + } + } +} + func TestEditFeed(t *testing.T) { s, h := newServer(t) write(t, s, dayLine+"https://a.com\tA\tx\nhttps://b.com\tB\t\n")