mirror of
https://github.com/avelino/awesome-go.git
synced 2024-11-07 16:33:40 +00:00
Update test to 1.7 and display correct sorting order (#1219)
* Update test to 1.7 and display correct sorting order * Fix potential issue with goroutine exiting prematurely * Better naming for category * Remove unnecesarry format
This commit is contained in:
parent
ddbade8cea
commit
9b9606baba
@ -1,7 +1,7 @@
|
|||||||
language: go
|
language: go
|
||||||
|
|
||||||
go:
|
go:
|
||||||
- 1.4
|
- 1.7
|
||||||
|
|
||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
|
35
repo_test.go
35
repo_test.go
@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -25,19 +24,18 @@ func TestDuplicatedLinks(t *testing.T) {
|
|||||||
links := make(map[string]bool, 0)
|
links := make(map[string]bool, 0)
|
||||||
|
|
||||||
query.Find("body a").Each(func(_ int, s *goquery.Selection) {
|
query.Find("body a").Each(func(_ int, s *goquery.Selection) {
|
||||||
href, ok := s.Attr("href")
|
t.Run(s.Text(), func(t *testing.T) {
|
||||||
if !ok {
|
href, ok := s.Attr("href")
|
||||||
log.Printf("expected '%s' href", s)
|
if !ok {
|
||||||
t.Fail()
|
t.Error("expected to have href")
|
||||||
}
|
}
|
||||||
|
|
||||||
if links[href] {
|
if links[href] {
|
||||||
log.Printf("duplicated link '%s'", href)
|
t.Fatalf("duplicated link '%s'", href)
|
||||||
t.Fail()
|
}
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
links[href] = true
|
links[href] = true
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +44,12 @@ func testList(t *testing.T, list *goquery.Selection) {
|
|||||||
testList(t, items)
|
testList(t, items)
|
||||||
items.RemoveFiltered("ul")
|
items.RemoveFiltered("ul")
|
||||||
})
|
})
|
||||||
checkAlphabeticOrder(t, list)
|
|
||||||
|
category := list.Prev().Text()
|
||||||
|
|
||||||
|
t.Run(category, func(t *testing.T) {
|
||||||
|
checkAlphabeticOrder(t, list)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func readme() []byte {
|
func readme() []byte {
|
||||||
@ -80,8 +83,10 @@ func checkAlphabeticOrder(t *testing.T, s *goquery.Selection) {
|
|||||||
|
|
||||||
for k, item := range items {
|
for k, item := range items {
|
||||||
if item != sorted[k] {
|
if item != sorted[k] {
|
||||||
log.Printf("expected '%s' but actual is '%s'", sorted[k], item)
|
t.Errorf("expected '%s' but actual is '%s'", sorted[k], item)
|
||||||
t.Fail()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if t.Failed() {
|
||||||
|
t.Logf("expected order is:\n%s", strings.Join(sorted, "\n"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user