Skip to content

Commit

Permalink
Start timer for solution check on first crawl
Browse files Browse the repository at this point in the history
Initially timer for solution check starts when tests starts. However, it makes only sense to start the timer after a crawl has been made. As @zyhazwraith has pointed out in issue loong#3, if we crawl within the first second, the tests will fail a correct solution.

This closes loong#3
  • Loading branch information
loong committed Mar 31, 2017
1 parent 97ac37c commit 7b6f224
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions 0-limit-crawler/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ import (
func TestMain(t *testing.T) {
fetchSig := fetchSignalInstance()

start := time.Now()
go func() {
start := time.Unix(0, 0)
go func(start time.Time) {
for {
switch {
case <-fetchSig:
// Check if signal arrived earlier than a second (with error margin)
if time.Now().Sub(start).Nanoseconds() < 990000000 {
t.Log("There exists a two crawls who were executed less than 1 sec apart.")
if time.Now().Sub(start).Nanoseconds() < 950000000 {
t.Log("There exists a two crawls that were executed less than 1 second apart.")
t.Log("Solution is incorrect.")
t.FailNow()
}
start = time.Now()
}
}
}()
}(start)

main()
}

0 comments on commit 7b6f224

Please sign in to comment.