This repository has been archived on 2023-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
dex/storage/sql/migrate_test.go

35 lines
602 B
Go
Raw Normal View History

package sql
import (
"database/sql"
"os"
"testing"
"github.com/Sirupsen/logrus"
)
func TestMigrate(t *testing.T) {
db, err := sql.Open("sqlite3", ":memory:")
if err != nil {
t.Fatal(err)
}
defer db.Close()
logger := &logrus.Logger{
Out: os.Stderr,
Formatter: &logrus.TextFormatter{DisableColors: true},
Level: logrus.DebugLevel,
}
c := &conn{db, flavorSQLite3, logger}
for _, want := range []int{len(migrations), 0} {
got, err := c.migrate()
if err != nil {
t.Fatal(err)
}
if got != want {
t.Errorf("expected %d migrations, got %d", want, got)
}
}
}