Remove tests dependency from nullreader test

Previously we had a dependency to the tests package. As the
nullreader package is in the pkg directory it should be publicly
available. However, having the tests dependency could lead to a
transitive dependency to an internal package, if the tests package
would import one. Thus, we removed it.
This commit is contained in:
sirkrypt0
2021-07-20 22:43:31 +02:00
parent 8b26ecbe5f
commit 909f347d2f

View File

@ -3,10 +3,12 @@ package nullreader
import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gitlab.hpi.de/codeocean/codemoon/poseidon/tests"
"testing"
"time"
)
const shortTimeout = 100 * time.Millisecond
func TestNullReaderDoesNotReturnImmediately(t *testing.T) {
reader := &NullReader{}
readerReturned := make(chan bool)
@ -16,5 +18,14 @@ func TestNullReaderDoesNotReturnImmediately(t *testing.T) {
require.NoError(t, err)
close(readerReturned)
}()
assert.False(t, tests.ChannelReceivesSomething(readerReturned, tests.ShortTimeout))
var received bool
select {
case <-readerReturned:
received = true
case <-time.After(shortTimeout):
received = false
}
assert.False(t, received)
}