Commit 525223c2 authored by Steven's avatar Steven

chore: add tests for migrator

parent 96b9269c
...@@ -29,11 +29,6 @@ func GetMinorVersion(version string) string { ...@@ -29,11 +29,6 @@ func GetMinorVersion(version string) string {
return versionList[0] + "." + versionList[1] return versionList[0] + "." + versionList[1]
} }
func GetSchemaVersion(version string) string {
minorVersion := GetMinorVersion(version)
return minorVersion + ".0"
}
// IsVersionGreaterOrEqualThan returns true if version is greater than or equal to target. // IsVersionGreaterOrEqualThan returns true if version is greater than or equal to target.
func IsVersionGreaterOrEqualThan(version, target string) bool { func IsVersionGreaterOrEqualThan(version, target string) bool {
return semver.Compare(fmt.Sprintf("v%s", version), fmt.Sprintf("v%s", target)) > -1 return semver.Compare(fmt.Sprintf("v%s", version), fmt.Sprintf("v%s", target)) > -1
......
...@@ -39,10 +39,6 @@ func NewDB(profile *profile.Profile) (store.Driver, error) { ...@@ -39,10 +39,6 @@ func NewDB(profile *profile.Profile) (store.Driver, error) {
return &driver, nil return &driver, nil
} }
func (*DB) Type() string {
return "mysql"
}
func (d *DB) GetDB() *sql.DB { func (d *DB) GetDB() *sql.DB {
return d.db return d.db
} }
......
...@@ -39,10 +39,6 @@ func NewDB(profile *profile.Profile) (store.Driver, error) { ...@@ -39,10 +39,6 @@ func NewDB(profile *profile.Profile) (store.Driver, error) {
return driver, nil return driver, nil
} }
func (*DB) Type() string {
return "postgres"
}
func (d *DB) GetDB() *sql.DB { func (d *DB) GetDB() *sql.DB {
return d.db return d.db
} }
......
...@@ -50,10 +50,6 @@ func NewDB(profile *profile.Profile) (store.Driver, error) { ...@@ -50,10 +50,6 @@ func NewDB(profile *profile.Profile) (store.Driver, error) {
return &driver, nil return &driver, nil
} }
func (*DB) Type() string {
return "sqlite"
}
func (d *DB) GetDB() *sql.DB { func (d *DB) GetDB() *sql.DB {
return d.db return d.db
} }
......
...@@ -11,10 +11,6 @@ type Driver interface { ...@@ -11,10 +11,6 @@ type Driver interface {
GetDB() *sql.DB GetDB() *sql.DB
Close() error Close() error
// Type returns the type of the driver.
// Supported types are: sqlite, mysql, postgres.
Type() string
// MigrationHistory model related methods. // MigrationHistory model related methods.
FindMigrationHistoryList(ctx context.Context, find *FindMigrationHistory) ([]*MigrationHistory, error) FindMigrationHistoryList(ctx context.Context, find *FindMigrationHistory) ([]*MigrationHistory, error)
UpsertMigrationHistory(ctx context.Context, upsert *UpsertMigrationHistory) (*MigrationHistory, error) UpsertMigrationHistory(ctx context.Context, upsert *UpsertMigrationHistory) (*MigrationHistory, error)
......
This diff is collapsed.
package teststore
import (
"context"
"testing"
"github.com/stretchr/testify/require"
)
func TestGetCurrentSchemaVersion(t *testing.T) {
ctx := context.Background()
ts := NewTestingStore(ctx, t)
currentSchemaVersion, err := ts.GetCurrentSchemaVersion()
require.NoError(t, err)
require.Equal(t, "0.22.4", currentSchemaVersion)
}
...@@ -32,7 +32,7 @@ func GetTestingProfile(t *testing.T) *profile.Profile { ...@@ -32,7 +32,7 @@ func GetTestingProfile(t *testing.T) *profile.Profile {
// Get a temporary directory for the test data. // Get a temporary directory for the test data.
dir := t.TempDir() dir := t.TempDir()
mode := "dev" mode := "prod"
port := getUnusedPort() port := getUnusedPort()
driver := getDriverFromEnv() driver := getDriverFromEnv()
dsn := os.Getenv("DSN") dsn := os.Getenv("DSN")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment