2018-09-05 18:40:37 +02:00
|
|
|
package database
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/apex/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestConnect(t *testing.T) {
|
|
|
|
tmpfile, err := ioutil.TempFile("", "dbtest")
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
2018-09-06 15:34:56 +02:00
|
|
|
defer os.Remove(tmpfile.Name())
|
|
|
|
|
2018-09-05 18:40:37 +02:00
|
|
|
sess, err := Connect(tmpfile.Name())
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
colls, err := sess.Collections()
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(colls) < 1 {
|
|
|
|
log.Fatal("missing tables")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|