Added more tests and refactored exporter tests. Added code coverage badge.

This commit is contained in:
Musab Gültekin
2019-07-02 14:53:06 +03:00
parent 4ab7cfd904
commit b355a566cf
9 changed files with 144 additions and 17 deletions

View File

@@ -92,7 +92,7 @@ func TestAllLinks(t *testing.T) {
func TestStartRequestsFunc(t *testing.T) {
geziyor.NewGeziyor(&geziyor.Options{
StartRequestsFunc: func(g *geziyor.Geziyor) {
g.Get("http://quotes.toscrape.com/", g.Opt.ParseFunc)
g.Get("http://quotes.toscrape.com/", nil)
},
ParseFunc: func(g *geziyor.Geziyor, r *client.Response) {
r.HTMLDoc.Find("a").Each(func(_ int, s *goquery.Selection) {
@@ -223,6 +223,15 @@ func TestRedirect(t *testing.T) {
}).Start()
}
func TestConcurrentRequests(t *testing.T) {
defer leaktest.Check(t)()
geziyor.NewGeziyor(&geziyor.Options{
StartURLs: []string{"https://httpbin.org/delay/1", "https://httpbin.org/delay/2"},
ConcurrentRequests: 1,
ConcurrentRequestsPerDomain: 1,
}).Start()
}
// Make sure to increase open file descriptor limits before running
func BenchmarkRequests(b *testing.B) {