awesome-go/repo_test.go
Ceriath a25e27d1cb End description with dot (#2283)
* End description with dot

Make sure a description always ends with a dot.

* update (#1)

* Add me to maintainers list (#2238)

* Http clients (#2237)

* Remove gorequest

This does not really meet the required quality https://goreportcard.com/report/github.com/parnurzeal/gorequest

* Add HTTP-Clients category and sling

* Add grequests

* I suck at pressing ctrl+f

* Add Hoverfly API simulation tool (#2214)

* Update README.md (#2236)

* Add did (#2235)

* Add errorx (#2231)

* Add errorx

* fix errorx description

* Remove Florest, no longer exist (#2239)

* Add go-zero-width (#2242)

* Deprecate Go-AWS-Auth (#2243)

* Add huego. Updated README (#2241)

* Add Octillery (#2244)

* Remove github.com/GeertJohan/yubigo (#2247)

* Remove github.com/rcrowley/go-metric (#2246)

* Add a link to fastcache (#2249)

* Added iso601 (#2250)

* Remove mgutz/dat (#2251)

* No PR reviews
* last Commits on Mar 28, 2017

* Add mole (#2210)

* Deprecate github.com/FiloSottile/gvt (#2256)

* Deprecate github.com/sevki/graphql (#2257)

* Deprecate github.com/gonum/matrix (#2258)

* Deprecate github.com/fatih/structs (#2259)

* Deprecate github.com/toby3d/go-telegraph (#2260)

* Deprecate github.com/mitchellh/goamz (#2261)

* Deprecate github.com/franela/goreq (#2262)

* Deprecate github.com/facebookgo/httpcontrol (#2263)

* Deprecate github.com/markbates/validate (#2264)

* Deprecate github.com/codehack/go-relax (#2265)

* Deprecate github.com/volatile/core (#2266)

* Deprecate github.com/imdario/medeina (#2267)

* Deprecate github.com/daryl/zeus (#2268)

* Deprecate github.com/mvdan/interfacer (#2269)

* Deprecate github.com/GoClipse/goclipse (#2270)

* Add gonum (#2273)

* Add gonum

* add period

* Update validate (#2271)

* Update validate package

* accidentally removed a word, add it again

* Update go-telegraph (#2272)

* Remove https://github.com/bmizerany/pat (#2252)

* Commits on Aug 15, 2017
* PR No reviews

* fix project link (#2278)

* Add llir/llvm (#2279)

* Koazee (#2248)

Please check if what you want to add to `awesome-go` list meets [quality standards](https://github.com/avelino/awesome-go/blob/master/CONTRIBUTING.md#quality-standard) before sending pull request. Thanks!

**Please provide package links to:**

- github.com repo: https://github.com/wesovilabs/koazee
- godoc.org: https://godoc.org/github.com/wesovilabs/koazee
- goreportcard.com:  https://goreportcard.com/report/github.com/wesovilabs/koazee
- coverage service link ([cover.run](https://cover.run/), [gocover](http://gocover.io/), [coveralls](https://coveralls.io/) etc.), example: `[![cover.run](https://cover.run/go/github.com/user/repository.svg?style=flat&tag=golang-1.10)](https://cover.run/go?tag=golang-1.10&repo=github.com%2Fuser%2Frepository)`

[![codecov](https://codecov.io/gh/wesovilabs/koazee/branch/master/graph/badge.svg)](https://codecov.io/gh/wesovilabs/koazee)


 
Very good coverage

**Note**: that new categories can be added only when there are 3 packages or more.

**Make sure that you've checked the boxes below before you submit PR:**
- [x] I have added my package in alphabetical order.
- [x] I have an appropriate description with correct grammar.
- [x] I know that this package was not listed before.
- [x] I have added godoc link to the repo and to my pull request.
- [x] I have added coverage service link to the repo and to my pull request.
- [x] I have added goreportcard link to the repo and to my pull request.
- [x] I have read [Contribution guidelines](https://github.com/avelino/awesome-go/blob/master/CONTRIBUTING.md#contribution-guidelines), [maintainers note](https://github.com/avelino/awesome-go/blob/master/CONTRIBUTING.md#maintainers) and [Quality standard](https://github.com/avelino/awesome-go/blob/master/CONTRIBUTING.md#quality-standard).

Thanks for your PR, you're awesome! 👍

* Allow exclamation mark

* updated error message

* add various dots

* follow-up (#2)

* Revert "update (#1)" (#3)

This reverts commit 3e410e38c4.

* Missed some dots
2018-12-14 09:45:07 -02:00

125 lines
2.7 KiB
Go

package main
import (
"bytes"
"io/ioutil"
"regexp"
"sort"
"strings"
"testing"
"github.com/PuerkitoBio/goquery"
"github.com/russross/blackfriday"
)
func TestAlpha(t *testing.T) {
query := startQuery()
query.Find("body > ul").Each(func(_ int, s *goquery.Selection) {
testList(t, s)
})
}
func TestDuplicatedLinks(t *testing.T) {
query := startQuery()
links := make(map[string]bool, 0)
query.Find("body li > a:first-child").Each(func(_ int, s *goquery.Selection) {
t.Run(s.Text(), func(t *testing.T) {
href, ok := s.Attr("href")
if !ok {
t.Error("expected to have href")
}
if links[href] {
t.Fatalf("duplicated link '%s'", href)
}
links[href] = true
})
})
}
var (
reContainsLink = regexp.MustCompile(`\* \[.*\]\(.*\)`)
reOnlyLink = regexp.MustCompile(`\* \[.*\]\(.*\)$`)
reLinkWithDescription = regexp.MustCompile(`\* \[.*\]\(.*\) - \S.*[\.\!]`)
)
// Test if an entry has description, it must be separated from link with ` - `
func TestSeparator(t *testing.T) {
var matched, containsLink, noDescription bool
input, err := ioutil.ReadFile("./README.md")
if err != nil {
panic(err)
}
lines := strings.Split(string(input), "\n")
for _, line := range lines {
line = strings.Trim(line, " ")
containsLink = reContainsLink.MatchString(line)
if containsLink {
noDescription = reOnlyLink.MatchString(line)
if noDescription {
continue
}
matched = reLinkWithDescription.MatchString(line)
if !matched {
t.Errorf("expected entry to be in form of `* [link] - description.`, got '%s'", line)
}
}
}
}
func testList(t *testing.T, list *goquery.Selection) {
list.Find("ul").Each(func(_ int, items *goquery.Selection) {
testList(t, items)
items.RemoveFiltered("ul")
})
category := list.Prev().Text()
t.Run(category, func(t *testing.T) {
checkAlphabeticOrder(t, list)
})
}
func readme() []byte {
input, err := ioutil.ReadFile("./README.md")
if err != nil {
panic(err)
}
html := append([]byte("<body>"), blackfriday.MarkdownCommon(input)...)
html = append(html, []byte("</body>")...)
return html
}
func startQuery() *goquery.Document {
buf := bytes.NewBuffer(readme())
query, err := goquery.NewDocumentFromReader(buf)
if err != nil {
panic(err)
}
return query
}
func checkAlphabeticOrder(t *testing.T, s *goquery.Selection) {
items := s.Find("li > a:first-child").Map(func(_ int, li *goquery.Selection) string {
return strings.ToLower(li.Text())
})
sorted := make([]string, len(items))
copy(sorted, items)
sort.Strings(sorted)
for k, item := range items {
if item != sorted[k] {
t.Errorf("expected '%s' but actual is '%s'", sorted[k], item)
}
}
if t.Failed() {
t.Logf("expected order is:\n%s", strings.Join(sorted, "\n"))
}
}