From 3d9d9d0d3c770d4fdbf0ff239dabfbfe4bafee19 Mon Sep 17 00:00:00 2001 From: Viet Hung Nguyen Date: Thu, 31 Aug 2017 11:18:01 +0700 Subject: [PATCH] Add test to find out malformed separators. (#1564) Fix all links failed the test. --- README.md | 18 +++++++++--------- repo_test.go | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index fe1daeaf..0a8fddda 100644 --- a/README.md +++ b/README.md @@ -477,7 +477,7 @@ Please take a quick gander at the [contribution guidelines](https://github.com/a *Libraries for working with forms.* -* [bind](https://github.com/robfig/bind) - Bind form data to any Go values. +* [bind](https://github.com/robfig/bind) - Bind form data to any Go values. * [binding](https://github.com/mholt/binding) - Binds form and JSON data from net/http Request to struct. * [conform](https://github.com/leebenson/conform) - Keeps user input in check. Trims, sanitizes & scrubs data based on struct tags. * [form](https://github.com/go-playground/form) - Decodes url.Values into Go value(s) and Encodes Go value(s) into url.Values. Dual Array and Full map support. @@ -640,7 +640,7 @@ See [go-hardware](https://github.com/rakyll/go-hardware) for a comprehensive lis * [lumberjack](https://github.com/natefinch/lumberjack) - Simple rolling logger, implements io.WriteCloser. * [mlog](https://github.com/jbrodriguez/mlog) - Simple logging module for go, with 5 levels, an optional rotating logfile feature and stdout/stderr output. * [ozzo-log](https://github.com/go-ozzo/ozzo-log) - High performance logging supporting log severity, categorization, and filtering. Can send filtered log messages to various targets (e.g. console, network, mail). -* [seelog](https://github.com/cihub/seelog) - logging functionality with flexible dispatching, filtering, and formatting. +* [seelog](https://github.com/cihub/seelog) - Logging functionality with flexible dispatching, filtering, and formatting. * [slf](https://github.com/ventu-io/slf) - The Structured Logging Facade (SLF) for Go (like SLF4J but structured and for Go). * [slog](https://github.com/ventu-io/slog) - The reference implementation of the Structured Logging Facade (SLF) for Go. * [spew](https://github.com/davecgh/go-spew) - Implements a deep pretty printer for Go data structures to aid in debugging. @@ -1031,7 +1031,7 @@ See [go-hardware](https://github.com/rakyll/go-hardware) for a comprehensive lis * [go-txdb](https://github.com/DATA-DOG/go-txdb) - Single transaction based database driver mainly for testing purposes. * [gock](https://github.com/h2non/gock) - Versatile HTTP mocking made easy. * [gomock](https://github.com/golang/mock) - Mocking framework for the Go programming language. - * [govcr](https://github.com/seborama/govcr) - HTTP mock for Golang: record and replay HTTP interactions for offline testing. + * [govcr](https://github.com/seborama/govcr) - HTTP mock for Golang: record and replay HTTP interactions for offline testing. * [minimock](https://github.com/gojuno/minimock) - Mock generator for Go interfaces. * [mockhttp](https://github.com/tv42/mockhttp) - Mock object for Go http.ResponseWriter. @@ -1101,7 +1101,7 @@ See [go-hardware](https://github.com/rakyll/go-hardware) for a comprehensive lis * [cachet](https://github.com/andygrunwald/cachet) - Go client library for [Cachet (open source status page system)](https://cachethq.io/). * [circleci](https://github.com/jszwedko/go-circleci) - Go client library for interacting with CircleCI's API. * [clarifai](https://github.com/samuelcouch/clarifai) - Go client library for interfacing with the Clarifai API. -* [discordgo](https://github.com/bwmarrin/discordgo) - Go bindings for the Discord Chat API. +* [discordgo](https://github.com/bwmarrin/discordgo) - Go bindings for the Discord Chat API. * [facebook](https://github.com/huandu/facebook) - Go Library that supports the Facebook Graph API. * [fcm](https://github.com/maddevsio/fcm) - Go library for Firebase Cloud Messaging. * [gads](https://github.com/emiddleton/gads) - Google Adwords Unofficial API. @@ -1417,7 +1417,7 @@ See [go-hardware](https://github.com/rakyll/go-hardware) for a comprehensive lis * [errcheck](https://github.com/kisielk/errcheck) - Errcheck is a program for checking for unchecked errors in Go programs. * [gcvis](https://github.com/davecheney/gcvis) - Visualise Go program GC trace data in real time. * [Go Metalinter](https://github.com/alecthomas/gometalinter) - Metalinter is a tool to automatically apply all static analysis tool and report their output in normalized form. -* [go-checkstyle](https://github.com/qiniu/checkstyle) checkstyle is a style check tool like java checkstyle. This tool inspired by java checkstyle, golint. The style refered to some points in Go Code Review Comments. +* [go-checkstyle](https://github.com/qiniu/checkstyle) - checkstyle is a style check tool like java checkstyle. This tool inspired by java checkstyle, golint. The style refered to some points in Go Code Review Comments. * [go-cleanarch](https://github.com/roblaszczak/go-cleanarch) - go-cleanarch was created to validate Clean Architecture rules, like a The Dependency Rule and interaction between packages in your Go projects. * [go-outdated](https://github.com/firstrow/go-outdated) - Console application that displays outdated packages. * [goast-viewer](https://github.com/yuroyoro/goast-viewer) - Web based Golang AST visualizer. @@ -1488,7 +1488,7 @@ See [go-hardware](https://github.com/rakyll/go-hardware) for a comprehensive lis * [govvv](https://github.com/ahmetalpbalkan/govvv) - “go build” wrapper to easily add version information into Go binaries. * [gox](https://github.com/mitchellh/gox) - Dead simple, no frills Go cross compile tool. * [goxc](https://github.com/laher/goxc) - build tool for Go, with a focus on cross-compiling and packaging. -* [grapes](https://github.com/yaronsumel/grapes) - lightweight tool designed to distribute commands over ssh with ease. +* [grapes](https://github.com/yaronsumel/grapes) - Lightweight tool designed to distribute commands over ssh with ease. * [GVM](https://github.com/moovweb/gvm) - GVM provides an interface to manage Go versions. * [Hey](https://github.com/rakyll/hey) - Hey is a tiny program that sends some load to a web application. * [kala](https://github.com/ajvb/kala) - Simplistic, modern, and performant job scheduler. @@ -1529,9 +1529,9 @@ See [go-hardware](https://github.com/rakyll/go-hardware) for a comprehensive lis * [JayDiff](https://github.com/yazgazan/jaydiff) - JSON diff utility written in Go. * [Juju](https://jujucharms.com/) - Cloud-agnostic service deployment and orchestration - supports EC2, Azure, Openstack, MAAS and more. * [Leaps](https://github.com/jeffail/leaps) - Pair programming service using Operational Transforms. -* [limetext](http://limetext.org/) Lime Text is a powerful and elegant text editor primarily developed in Go that aims to be a Free and open-source software successor to Sublime Text. -* [LiteIDE](https://github.com/visualfc/liteide) LiteIDE is a simple, open source, cross-platform Go IDE. -* [mockingjay](https://github.com/quii/mockingjay-server) Fake HTTP servers and consumer driven contracts from one configuration file. You can also make the server randomly misbehave to help do more realistic performance tests. +* [limetext](http://limetext.org/) - Lime Text is a powerful and elegant text editor primarily developed in Go that aims to be a Free and open-source software successor to Sublime Text. +* [LiteIDE](https://github.com/visualfc/liteide) - LiteIDE is a simple, open source, cross-platform Go IDE. +* [mockingjay](https://github.com/quii/mockingjay-server) - Fake HTTP servers and consumer driven contracts from one configuration file. You can also make the server randomly misbehave to help do more realistic performance tests. * [myLG](https://github.com/mehrdadrad/mylg) - Command Line Network Diagnostic tool written in Go. * [naclpipe](https://github.com/unix4fun/naclpipe) - Simple NaCL EC25519 based crypto pipe tool written in Go. * [nes](https://github.com/fogleman/nes) - Nintendo Entertainment System (NES) emulator written in Go. diff --git a/repo_test.go b/repo_test.go index 8bbff861..98bea17c 100644 --- a/repo_test.go +++ b/repo_test.go @@ -3,6 +3,7 @@ package main import ( "bytes" "io/ioutil" + "regexp" "sort" "strings" "testing" @@ -39,6 +40,37 @@ func TestDuplicatedLinks(t *testing.T) { }) } +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)