mirror of
https://github.com/avelino/awesome-go.git
synced 2024-12-12 17:13:58 +00:00
Merge branch 'test-duplicated-links' of github.com:avelino/awesome-go
* 'test-duplicated-links' of github.com:avelino/awesome-go: add scripts to test duplicated links
This commit is contained in:
commit
f341f2dbb2
21
repo_test.go
21
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)
|
||||
|
Loading…
Reference in New Issue
Block a user