diff options
author | Julien Dessaux | 2021-05-18 21:31:15 +0200 |
---|---|---|
committer | Julien Dessaux | 2021-05-18 21:31:15 +0200 |
commit | 8dadf747332ca5d5d3c2d25050a064949a88218e (patch) | |
tree | e00b4a2465168c340d4a9140cfff840843a8090c /pkg/database | |
parent | Updated dependencies (diff) | |
download | trains-8dadf747332ca5d5d3c2d25050a064949a88218e.tar.gz trains-8dadf747332ca5d5d3c2d25050a064949a88218e.tar.bz2 trains-8dadf747332ca5d5d3c2d25050a064949a88218e.zip |
Fixed database train_stop incomplete test
Diffstat (limited to '')
-rw-r--r-- | pkg/database/train_stop.go | 4 | ||||
-rw-r--r-- | pkg/database/train_stop_test.go | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/pkg/database/train_stop.go b/pkg/database/train_stop.go index 27fb910..452f6c3 100644 --- a/pkg/database/train_stop.go +++ b/pkg/database/train_stop.go @@ -1,6 +1,8 @@ package database -import "git.adyxax.org/adyxax/trains/pkg/model" +import ( + "git.adyxax.org/adyxax/trains/pkg/model" +) func (env *DBEnv) ReplaceAndImportTrainStops(trainStops []model.TrainStop) error { pre_query := `DELETE FROM train_stops;` diff --git a/pkg/database/train_stop_test.go b/pkg/database/train_stop_test.go index 9ee9c03..f593d51 100644 --- a/pkg/database/train_stop_test.go +++ b/pkg/database/train_stop_test.go @@ -73,7 +73,7 @@ func TestReplaceAndImportTrainStopsWithSQLMock(t *testing.T) { } defer dbCannotInsertError.Close() mockCannotInsertError.ExpectBegin() - mockCannotInsertError.ExpectExec(`DELETE FROM`) + mockCannotInsertError.ExpectExec(`DELETE FROM`).WillReturnResult(sqlmock.NewResult(1, 1)) // Transaction commit error dbCommitError, mockCommitError, err := sqlmock.New() if err != nil { @@ -81,8 +81,9 @@ func TestReplaceAndImportTrainStopsWithSQLMock(t *testing.T) { } defer dbCommitError.Close() mockCommitError.ExpectBegin() - mockCommitError.ExpectExec(`DELETE FROM`) - mockCommitError.ExpectExec(`INSERT INTO`) + mockCommitError.ExpectExec(`DELETE FROM`).WillReturnResult(sqlmock.NewResult(1, 1)) + mockCommitError.ExpectExec(`INSERT INTO`).WillReturnResult(sqlmock.NewResult(1, 1)) + mockCommitError.ExpectExec(`INSERT INTO`).WillReturnResult(sqlmock.NewResult(1, 1)) // Test cases testCases := []struct { name string @@ -92,7 +93,7 @@ func TestReplaceAndImportTrainStopsWithSQLMock(t *testing.T) { {"begin transaction error", &DBEnv{db: dbBeginError}, &TransactionError{}}, {"query error cannot delete from", &DBEnv{db: dbCannotDeleteFrom}, &QueryError{}}, {"query error cannot insert into", &DBEnv{db: dbCannotInsertError}, &QueryError{}}, - // TODO FIX THIS TEST {"commit transaction error", &DBEnv{db: dbCommitError}, &TransactionError{}}, + {"commit transaction error", &DBEnv{db: dbCommitError}, &TransactionError{}}, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { |