mirror of https://github.com/dexidp/dex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
602 B
34 lines
602 B
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) |
|
} |
|
} |
|
}
|
|
|