Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Mongo Go Driver | 7,632 | 6,060 | 21 hours ago | 330 | August 02, 2023 | 16 | apache-2.0 | Go | ||
The Official Golang driver for MongoDB | ||||||||||
Jepsen | 6,308 | 66 | 3 days ago | 39 | June 07, 2019 | 54 | Clojure | |||
A framework for distributed systems verification, with fault injection | ||||||||||
Gpdb | 5,928 | 4 hours ago | 415 | apache-2.0 | C | |||||
Greenplum Database - Massively Parallel PostgreSQL for Analytics. An open-source massively parallel data platform for analytics, machine learning and AI. | ||||||||||
Go Sqlmock | 5,425 | 1,336 | a month ago | 21 | June 28, 2020 | 75 | other | Go | ||
Sql mock driver for golang to test database interactions | ||||||||||
Toydb | 5,317 | 7 days ago | 5 | apache-2.0 | Rust | |||||
Distributed SQL database in Rust, written as a learning project | ||||||||||
Dockertest | 3,657 | 232 | 1,024 | 3 days ago | 88 | April 06, 2023 | 23 | apache-2.0 | Go | |
Write better integration tests! Dockertest helps you boot up ephermal docker images for your Go tests with minimal work. | ||||||||||
Test_db | 3,585 | a month ago | 2 | Shell | ||||||
A sample MySQL database with an integrated test suite, used to test your applications and database servers | ||||||||||
Nodejs Integration Tests Best Practices | 2,983 | 2 months ago | 42 | JavaScript | ||||||
✅ Beyond the basics of Node.js testing. Including a super-comprehensive best practices list and an example app (July 2022) | ||||||||||
Marten | 2,436 | 31 | 64 | 2 days ago | 206 | July 23, 2023 | 96 | mit | C# | |
.NET Transactional Document DB and Event Store on PostgreSQL | ||||||||||
Aresdb | 2,329 | 3 years ago | 21 | apache-2.0 | Go | |||||
A GPU-powered real-time analytics storage and query engine. |
database_rewinder is a minimalist's tiny and ultra-fast database cleaner.
database_rewinder memorizes every table name into which INSERT
SQL was performed during each test case.
Then it executes DELETE
SQL only against these tables when cleaning.
So, the more number of tables you have in your database, the more benefit you will get.
Also, database_rewinder joins all DELETE
SQL statements and casts it in one DB server call.
This strategy was originally devised and implemented by Shingo Morita (@eudoxa) at COOKPAD Inc.
ActiveRecord 4.2, 5.0, 5.1, 5.2, 6.0, 6.1, 7.0 (edge)
Ruby 2.4, 2.5, 2.6, 2.7, 3.0, 3.1 (trunk)
Add this line to your Gemfile's :test
group:
gem 'database_rewinder'
And then execute:
$ bundle
Do clean
in after(:each)
. And do clean_all
or clean_with
in before(:suite)
if you'd like to.
RSpec.configure do |config|
config.before(:suite) do
DatabaseRewinder.clean_all
# or
# DatabaseRewinder.clean_with :any_arg_that_would_be_actually_ignored_anyway
end
config.after(:each) do
DatabaseRewinder.clean
end
end
You can configure multiple DB connections to tell DatabaseRewinder to cleanup all of them after each test.
In order to add another connection, use DatabaseRewinder[]
method.
RSpec.configure do |config|
config.before(:suite) do
# simply give the DB connection names that are written in config/database.yml
DatabaseRewinder['test']
DatabaseRewinder['another_test_db']
# you could give the DB name with connection: key if you like
DatabaseRewinder[connection: 'yet_another_test_db']
# or with a meaningless something first, then {connection: DB_NAME} as the second argument (DatabaseCleaner compatible)
DatabaseRewinder[:active_record, connection: 'an_active_record_db']
DatabaseRewinder.clean_all
end
config.after(:each) do
DatabaseRewinder.clean
end
end
database_rewinder tries to create a new DB connection for deletion when you're running tests on MySQL.
You would occasionally hit some weird errors (e.g. query execution timeout) because of this, especially when your tests are run with the use_transactional_tests
option enabled (which is Rails' default).
use_transactional_tests
means, and consider turning it offuse_transactional_tests
is the option that surrounds each of your test case with a DB transaction to roll back all your test data after each test run.
So far as this works properly, you won't really need to use database_rewinder.
However, this simple mechanism doesn't work well when you're running integration tests with capybara + js mode.
In cases of this situation, bundle database_rewinder and add the following configuration.
RSpec.configure do |config|
config.use_transactional_tests = false
...
end
multiple: false
optionIf you're really sure you need to keep using transactional tests + database_rewinder for some reason, then explicitly pass in multiple: false
option to DatabaseRewinder.clean_all
and DatabaseRewinder.clean
invocations as follows. Note that you won't be able to get full performance merit that database_rewinder provides though.
RSpec.configure do |config|
config.before :suite do
DatabaseRewinder.clean_all multiple: false
end
config.after :each do
DatabaseRewinder.clean multiple: false
end
end
database_rewinder is designed to be almost compatible with database_cleaner. So the following code will probably let your existing app work under database_rewinder without making any change on your configuration.
DatabaseCleaner = DatabaseRewinder
Send me your pull requests.