Restructure project

We previously didn't really had any structure in our project apart
from creating a new folder for each package in our project root.
Now that we have accumulated some packages, we use the well-known
Golang project layout in order to clearly communicate our intent
with packages. See https://github.com/golang-standards/project-layout
This commit is contained in:
sirkrypt0
2021-07-16 09:19:42 +02:00
parent 2f1383b743
commit 8b26ecbe5f
66 changed files with 95 additions and 95 deletions

View File

@@ -0,0 +1,10 @@
package nullreader
// NullReader is a struct that implements the io.Reader interface and returns nothing when reading
// from it.
type NullReader struct{}
func (r NullReader) Read(_ []byte) (int, error) {
// An empty select blocks forever.
select {}
}

View File

@@ -0,0 +1,20 @@
package nullreader
import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gitlab.hpi.de/codeocean/codemoon/poseidon/tests"
"testing"
)
func TestNullReaderDoesNotReturnImmediately(t *testing.T) {
reader := &NullReader{}
readerReturned := make(chan bool)
go func() {
p := make([]byte, 0, 5)
_, err := reader.Read(p)
require.NoError(t, err)
close(readerReturned)
}()
assert.False(t, tests.ChannelReceivesSomething(readerReturned, tests.ShortTimeout))
}