Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 70b23c3

Browse files
committed
Relaxed constratint that method receiver has to be of Driver interface.
1 parent 223908f commit 70b23c3

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

driver/gomethods/gomethods_migrator.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"os"
99
"path"
1010
"bufio"
11-
"github.com/dimag-jfrog/migrate/driver"
1211
"github.com/dimag-jfrog/migrate/file"
1312
)
1413

@@ -31,7 +30,7 @@ func (e *MethodInvocationFailedError) Error() string {
3130

3231

3332
type Migrator struct {
34-
Driver driver.Driver
33+
MigrationMethodsReceiver interface{}
3534
RollbackOnFailure bool
3635
}
3736

@@ -73,12 +72,12 @@ func (m *Migrator) Migrate(f file.File, pipe chan interface{}) error {
7372
}
7473

7574
func (m *Migrator) IsValid(methodName string) bool {
76-
return reflect.ValueOf(m.Driver).MethodByName(methodName).IsValid()
75+
return reflect.ValueOf(m.MigrationMethodsReceiver).MethodByName(methodName).IsValid()
7776
}
7877

7978
func (m *Migrator) Invoke(methodName string) error {
8079
name := methodName
81-
migrateMethod := reflect.ValueOf(m.Driver).MethodByName(name)
80+
migrateMethod := reflect.ValueOf(m.MigrationMethodsReceiver).MethodByName(name)
8281
if !migrateMethod.IsValid() {
8382
return MissingMethodError(methodName)
8483
}

driver/gomethods/gomethods_migrator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func TestMigrate(t *testing.T) {
232232
for _, c := range cases {
233233
migrator := Migrator{}
234234
d := &FakeGoMethodsDriver{Migrator: migrator, InvokedMethods:[]string{}}
235-
migrator.Driver = d
235+
migrator.MigrationMethodsReceiver = d
236236
migrator.RollbackOnFailure = c.expectRollback
237237

238238
pipe := pipep.New()

driver/gomethods/usage_examples/mongodb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type GoMethodsMongoDbDriver struct {
1616
}
1717

1818
func (d *GoMethodsMongoDbDriver) Initialize(url string) error {
19-
return d.DriverTemplate.Initialize(url, DB_NAME, gomethods.Migrator{Driver: d})
19+
return d.DriverTemplate.Initialize(url, DB_NAME, gomethods.Migrator{MigrationMethodsReceiver: d})
2020
}
2121

2222
func init() {

driver/gomethods/usage_examples/mongodb_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func RunMigrationAndAssertResult(
6868
if !reflect.DeepEqual(expected.Errors, errs) {
6969
t.Fatalf("Migration '%s': FAILED\nexpected errors %v\nbut got %v", title, expected.Errors, errs)
7070
}
71+
t.Logf("Migration '%s': PASSED", title)
7172
}
7273

7374

0 commit comments

Comments
 (0)