golang-lib/database/main_test.go

36 lines
661 B
Go
Raw Normal View History

2017-05-17 16:17:02 +02:00
package database
2021-06-02 18:00:53 +02:00
import (
"testing"
"github.com/stretchr/testify/assert"
)
var (
// DBConnection - url to database on setting up default WebService for webtest
DBConnection = "user=root password=root dbname=defaultdb host=localhost port=26257 sslmode=disable"
)
func TestStatus(t *testing.T) {
assert := assert.New(t)
d := Database{
Debug: true,
}
err := d.Status()
assert.Error(err)
assert.Equal(ErrNotConnected, err)
err = d.Run()
assert.Error(err)
assert.Contains(err.Error(), "dial error")
d.Connection = DBConnection
err = d.Run()
assert.Error(err)
assert.Equal(ErrNothingToMigrate, err)
err = d.Status()
assert.NoError(err)
}