Skip to content

Commit

Permalink
Merge branch 'release/0.18.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpjose committed Jul 13, 2022
2 parents 02444ad + 797098b commit 3ab9a3c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
16 changes: 14 additions & 2 deletions event/producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,16 @@ func TestProducer_SearchDataImport(t *testing.T) {

var avroBytes []byte
var testTimeout = time.Second * 5
delay := time.NewTimer(testTimeout)
select {
case avroBytes = <-pChannels.Output:
// Ensure timer is stopped and its resources are freed
if !delay.Stop() {
// if the timer has been stopped then read from the channel
<-delay.C
}
t.Log("avro byte sent to producer output")
case <-time.After(testTimeout):
case <-delay.C:
t.Fatalf("failing test due to timing out after %v seconds", testTimeout)
t.FailNow()
}
Expand Down Expand Up @@ -180,10 +186,16 @@ func TestProducer_SearchDatasetVersionMetadataImport(t *testing.T) {

var avroBytes []byte
var testTimeout = time.Second * 5
delay := time.NewTimer(testTimeout)
select {
case avroBytes = <-pChannels.Output:
// Ensure timer is stopped and its resources are freed
if !delay.Stop() {
// if the timer has been stopped then read from the channel
<-delay.C
}
t.Log("avro byte sent to producer output")
case <-time.After(testTimeout):
case <-delay.C:
t.Fatalf("failing test due to timing out after %v seconds", testTimeout)
t.FailNow()
}
Expand Down
32 changes: 28 additions & 4 deletions handler/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,16 @@ func TestHandlerForZebedeeReturningMandatoryFields(t *testing.T) {
})

var avroBytes []byte
delay := time.NewTimer(testTimeout)
select {
case avroBytes = <-pChannels.Output:
// Ensure timer is stopped and its resources are freed
if !delay.Stop() {
// if the timer has been stopped then read from the channel
<-delay.C
}
t.Log("avro byte sent to producer output")
case <-time.After(testTimeout):
case <-delay.C:
t.FailNow()
}
Convey("And then the expected bytes are sent to producer.output", func() {
Expand Down Expand Up @@ -172,10 +178,16 @@ func TestHandlerForZebedeeReturningMandatoryFields(t *testing.T) {

So(len(datasetMock.GetVersionMetadataCalls()), ShouldEqual, 0)
})
delay := time.NewTimer(testTimeout)
select {
case <-pChannels.Output:
// Ensure timer is stopped and its resources are freed
if !delay.Stop() {
// if the timer has been stopped then read from the channel
<-delay.C
}
t.Log("avro byte sent to producer output")
case <-time.After(testTimeout):
case <-delay.C:
t.FailNow()
}
})
Expand Down Expand Up @@ -246,10 +258,16 @@ func TestHandlerForZebedeeReturningAllFields(t *testing.T) {
err := eventHandler.Handle(ctx, &testZebedeeEvent, *cfg)

var avroBytes []byte
delay := time.NewTimer(testTimeout)
select {
case avroBytes = <-pChannels.Output:
// Ensure timer is stopped and its resources are freed
if !delay.Stop() {
// if the timer has been stopped then read from the channel
<-delay.C
}
t.Log("avro byte sent to producer output")
case <-time.After(testTimeout):
case <-delay.C:
t.FailNow()
}
Convey("Then no error is reported", func() {
Expand Down Expand Up @@ -327,10 +345,16 @@ func TestHandlerForDatasetVersionMetadata(t *testing.T) {
err := eventHandler.Handle(ctx, &testDatasetEvent, *cfg)

var avroBytes []byte
delay := time.NewTimer(testTimeout)
select {
case avroBytes = <-pChannels.Output:
// Ensure timer is stopped and its resources are freed
if !delay.Stop() {
// if the timer has been stopped then read from the channel
<-delay.C
}
t.Log("avro byte sent to producer output")
case <-time.After(testTimeout):
case <-delay.C:
t.FailNow()
}

Expand Down

0 comments on commit 3ab9a3c

Please sign in to comment.