From 4b736762e71a5ab409d2c900b60a4cbe2fffc758 Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 23 Apr 2015 20:28:54 +0100 Subject: [PATCH] add scripts to test duplicated links --- repo_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/repo_test.go b/repo_test.go index 3386d7a3..d6e72627 100644 --- a/repo_test.go +++ b/repo_test.go @@ -20,6 +20,27 @@ func TestAlpha(t *testing.T) { }) } +func TestDuplicatedLinks(t *testing.T) { + query := startQuery() + links := make(map[string]bool, 0) + + query.Find("body a").Each(func(_ int, s *goquery.Selection) { + href, ok := s.Attr("href") + if !ok { + log.Printf("expected '%s' href", s) + t.Fail() + } + + if links[href] { + log.Printf("duplicated link '%s'", href) + t.Fail() + return + } + + links[href] = true + }) +} + func testList(t *testing.T, list *goquery.Selection) { list.Find("ul").Each(func(_ int, items *goquery.Selection) { testList(t, items)