Permalink
Browse files

issue #26: remove go 1.5-1.7 from travis

  • Loading branch information...
kamilsk committed Apr 30, 2018
1 parent 6e599cb commit e1775221a187ff0b9bc5c604542a5f8510e315bc
Showing with 63 additions and 15 deletions.
  1. +1 −8 .travis.yml
  2. +9 −7 http/availability/crawler.go
  3. +9 −0 http/availability/helper_test.go
  4. +44 −0 http/availability/report_test.go
@@ -3,10 +3,6 @@ language: go
go:
- master
- 1.x
# blocked by issue#39
#- 1.5.x
#- 1.6.x
#- 1.7.x
- 1.8.x
- 1.9.x
- 1.10.x
@@ -18,11 +14,8 @@ matrix:

sudo: false

#before_install:
#- export GO15VENDOREXPERIMENT=1

script:
- make test-with-coverage-profile ARGS='-timeout=1s'
- make test ARGS='-timeout=1s'

after_success:
- echo $TRAVIS_GO_VERSION ":" $TRAVIS_TAG
@@ -42,16 +42,18 @@ func CrawlerColly(config CrawlerConfig) Crawler {
if config.UserAgent != "" {
options = append(options, colly.UserAgent(config.UserAgent))
}
options = append(options, colly.IgnoreRobotsTxt())
if config.Verbose {
options = append(options, colly.Debugger(&debug.LogDebugger{Output: config.Output}))
}
options = append(options, NoCookie())
options = append(options, NoRedirect())
options = append(options, OnRequest())
options = append(options, OnError(bus))
options = append(options, OnResponse(bus))
options = append(options, OnHTML(base, bus))
options = append(options,
colly.IgnoreRobotsTxt(),
NoCookie(),
NoRedirect(),
OnRequest(),
OnError(bus),
OnResponse(bus),
OnHTML(base, bus),
)
return colly.NewCollector(options...).Visit(entry)
})
}
@@ -187,3 +187,12 @@ func (m *PrinterMock) Sites() <-chan availability.Site {
args := m.Called()
return args.Get(0).(<-chan availability.Site)
}

type CrawlerMock struct {
mock.Mock
}

func (m *CrawlerMock) Visit(url string, bus availability.EventBus) error {
args := m.Called(url, bus)
return args.Error(0)
}
@@ -1 +1,45 @@
package availability_test

import (
"testing"

"github.com/kamilsk/check/http/availability"
"github.com/stretchr/testify/assert"
)

func TestReporter(t *testing.T) {
tests := []struct {
name string
rawURLs []string
reporter func() *availability.Report
expected func() <-chan availability.Site
}{
{
"empty report",
nil,
func() *availability.Report { return availability.NewReport() },
func() <-chan availability.Site {
ch := make(chan availability.Site)
close(ch)
return ch
},
},
}
for _, test := range tests {
tc := test
t.Run(test.name, func(t *testing.T) {
obtainedPipe := tc.reporter().For(tc.rawURLs).Fill().Sites()
expectedPipe := tc.expected()
assert.Equal(t, len(expectedPipe), len(obtainedPipe))
obtained := make([]availability.Site, 0, len(obtainedPipe))
for site := range obtainedPipe {
obtained = append(obtained, site)
}
expected := make([]availability.Site, 0, len(expectedPipe))
for site := range expectedPipe {
expected = append(expected, site)
}
assert.Equal(t, expected, obtained)
})
}
}

0 comments on commit e177522

Please sign in to comment.