Skip to content

Commit

Permalink
add big tests
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Trofimov <qwerty65k@mail.ru>
  • Loading branch information
GOodCoffeeLover committed Aug 26, 2023
1 parent 199784f commit 6138e10
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion pkg/storage/driver/sql_test.go
Expand Up @@ -562,7 +562,54 @@ func TestCheckAlreadyAppliedNotFind(t *testing.T) {
mock.ExpectCommit()

if sqlDriver.checkAlreadyApplied(testMigrations) {
t.Errorf("Did find init id: %v, that not exists", initID)
t.Errorf("Did find init id: %v, that does not exist", initID)
}

}

func TestCheckAlreadyAppliedBigFind(t *testing.T) {
sqlDriver, mock := newTestFixtureSQL(t)

testMigrations := []*migrate.Migration{{Id: "init1"}, {Id: "init2"}, {Id: "init3"}}
mock.
ExpectQuery("").
WillReturnRows(
sqlmock.NewRows([]string{"id", "applied_at"}).
AddRow("1", time.Time{}).
AddRow("2", time.Time{}).
AddRow("init1", time.Time{}).
AddRow("init2", time.Time{}).
AddRow("3", time.Time{}).
AddRow("init3", time.Time{}).
AddRow("4", time.Time{}).
AddRow("5", time.Time{}))
mock.ExpectCommit()

if !sqlDriver.checkAlreadyApplied(testMigrations) {
t.Errorf("Did not find init ids, that exist")
}

}

func TestCheckAlreadyAppliedBigNotFind(t *testing.T) {
sqlDriver, mock := newTestFixtureSQL(t)

testMigrations := []*migrate.Migration{{Id: "init1"}, {Id: "init2"}, {Id: "init3"}}
mock.
ExpectQuery("").
WillReturnRows(
sqlmock.NewRows([]string{"id", "applied_at"}).
AddRow("1", time.Time{}).
AddRow("2", time.Time{}).
AddRow("init1", time.Time{}).
AddRow("3", time.Time{}).
AddRow("init2", time.Time{}).
AddRow("4", time.Time{}).
AddRow("5", time.Time{}))
mock.ExpectCommit()

if sqlDriver.checkAlreadyApplied(testMigrations) {
t.Errorf("Did not find init id: init3, that does not exist")
}

}

0 comments on commit 6138e10

Please sign in to comment.