Skip to content

Commit

Permalink
add scripts to test duplicated links
Browse files Browse the repository at this point in the history
  • Loading branch information
Duke committed Apr 23, 2015
1 parent b814c1c commit 4b73676
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4b73676

Please sign in to comment.