Add tests for codeOceanToRaw and null readers

The tests ensure the readers do not return when there is no data
available.
This commit is contained in:
Konrad Hanff
2021-06-18 09:14:07 +02:00
parent 17c1e379c2
commit 92f1af83ae
3 changed files with 85 additions and 1 deletions

View File

@ -750,3 +750,19 @@ func (s *ExecuteCommandTestSuite) mockExecute(command interface{}, exitCode int,
Run(runFunc).
Return(exitCode, err)
}
func TestNullReaderDoesNotReturnImmediately(t *testing.T) {
reader := &nullReader{}
readerReturned := make(chan bool)
go func() {
p := make([]byte, 5)
_, _ = reader.Read(p)
close(readerReturned)
}()
select {
case <-readerReturned:
t.Fatal("Read should not return immediately.")
case <-time.After(tests.ShortTimeout):
}
}