WIP: tests of api pkg

This commit is contained in:
Julien Neuhart
2019-07-09 22:22:22 +02:00
parent c7ecdcf625
commit 0c1e4e6888
8 changed files with 67 additions and 11 deletions

View File

@@ -30,6 +30,16 @@ func AssertStatusCode(t *testing.T, expectedStatusCode int, srv http.Handler, re
assert.Equal(t, expectedStatusCode, rec.Code)
}
// AssertDirectoryEmpty checks if given directory
// is empty.
func AssertDirectoryEmpty(t *testing.T, directory string) {
f, err := os.Open(directory)
assert.Nil(t, err)
defer f.Close() // nolint: errcheck
_, err = f.Readdir(1)
assert.Equal(t, io.EOF, err)
}
// AssertConcurrent runs all functions simultaneously
// and wait until execution has completed
// or an error is encountered.