1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-03-05 15:16:07 +02:00

Code coverage (#134)

* Added code coverage report
This commit is contained in:
Tim Voronov 2018-10-16 20:50:06 -04:00 committed by GitHub
parent ca1f0cd65a
commit 7dc1288bae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 10 deletions

3
.gitignore vendored
View File

@ -126,4 +126,5 @@ vendor
bin
*.log
*.orig
dist
dist
coverage.txt

View File

@ -47,11 +47,14 @@ jobs:
- make generate
- make compile
- stage: test
script: make test
- stage: e2e
script:
- make cover
after_success:
- bash <(curl -s https://codecov.io/bash)
- stage: e2e
before_script:
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 --disable-setuid-sandbox --no-sandbox about:blank &
script:
- make e2e
after_script:
- killall google-chrome-stable
after_script:
- killall google-chrome-stable

View File

@ -21,7 +21,10 @@ install:
dep ensure
test:
go test ${DIR_PKG}/...
go test -race ${DIR_PKG}/...
cover:
go test -race -coverprofile=coverage.txt -covermode=atomic ${DIR_PKG}/...
e2e:
go run ${DIR_E2E}/main.go --tests ${DIR_E2E}/tests --pages ${DIR_E2E}/pages

View File

@ -6,6 +6,7 @@ import (
"github.com/mafredri/cdp/protocol/page"
. "github.com/smartystreets/goconvey/convey"
"golang.org/x/sync/errgroup"
"sync/atomic"
"testing"
"time"
)
@ -293,9 +294,10 @@ func TestEventBroker(t *testing.T) {
b := NewTestEventBroker()
b.Start()
counter := 0
var counter int64
b.AddEventListener(events.EventLoad, func(message interface{}) {
counter++
atomic.AddInt64(&counter, 1)
b.Stop()
})
@ -313,7 +315,7 @@ func TestEventBroker(t *testing.T) {
time.Sleep(time.Duration(5) * time.Millisecond)
So(counter, ShouldEqual, 1)
So(atomic.LoadInt64(&counter), ShouldEqual, 1)
})
})
}