Closed ninadingole closed 2 months ago
closes #316
func TestContextBeginWithTxOptions(t *testing.T) { t.Parallel() db, mock, err := New() if err != nil { t.Errorf("an error '%s' was not expected when opening a stub database connection", err) } defer db.Close() mock.ExpectBegin().WithTxOptions(sql.TxOptions{ Isolation: sql.LevelReadCommitted, ReadOnly: true, }) ctx, cancel := context.WithCancel(context.Background()) go func() { time.Sleep(time.Millisecond * 10) cancel() }() _, err = db.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelReadCommitted, ReadOnly: false}) if err != nil { t.Errorf("error was not expected, but got: %v", err) } if err := mock.ExpectationsWereMet(); err != nil { t.Errorf("there were unfulfilled expectations: %s", err) } }
there is a bug in the current implementation, please check https://github.com/DATA-DOG/go-sqlmock/issues/342
closes #316