Remove monkey dependency

This commit is contained in:
Jannis Mattheis
2018-11-06 20:58:35 +01:00
parent 0f9d3bde81
commit 80eec6ae3a
9 changed files with 51 additions and 54 deletions

View File

@@ -1,12 +1,10 @@
package database
import (
"errors"
"os"
"testing"
"errors"
"github.com/bouk/monkey"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
@@ -62,12 +60,11 @@ func TestWithAlreadyExistingSqliteFolder(t *testing.T) {
}
func TestPanicsOnMkdirError(t *testing.T) {
patch := monkey.Patch(os.MkdirAll, func(string, os.FileMode) error { return errors.New("whoops") })
defer patch.Unpatch()
// ensure path not exists
os.RemoveAll("somepath")
mkdirAll = func(path string, perm os.FileMode) error {
return errors.New("ERROR")
}
assert.Panics(t, func() {
New("sqlite3", "somepath/testdb.db", "defaultUser", "defaultPass", 5, true)
New("sqlite3", "somepath/test.db", "defaultUser", "defaultPass", 5, true)
})
}