Skip to content

Instantly share code, notes, and snippets.

@philsquared
Created January 14, 2019 10:09
Show Gist options
  • Save philsquared/19e44ca2dff13d1b9ba1704bb752b7bb to your computer and use it in GitHub Desktop.
Save philsquared/19e44ca2dff13d1b9ba1704bb752b7bb to your computer and use it in GitHub Desktop.
Kellabyte's rewind tests using BDD (depends on https://gist.github.com/philsquared/567fdd233d574fe1957d17aff3e5d02c)
SCENARIO("initialize rewind", "[rewind]") {
GIVEN( "an uninitialised environment") {
int rc;
MDB_env *env;
MDB_dbi dbi;
MDB_txn *txn;
WHEN("an environment is created and opened") {
REQUIRE(SuccessFrom(mdb_env_create(&env)));
REQUIRE(SuccessFrom(mdb_env_set_mapsize(env, size_t(1048576000))));
REQUIRE(SuccessFrom(mdb_env_set_maxdbs(env, 1024)));
REQUIRE(SuccessFrom(mdb_env_open(env, "/tmp", MDB_FIXEDMAP /*|MDB_NOSYNC*/, 0664)));
AND_WHEN("a transaction is begun") {
REQUIRE(SuccessFrom(mdb_txn_begin(env, NULL, 0, &txn)));
REQUIRE(SuccessFrom(mdb_dbi_open(txn, NULL, 0, &dbi)));
REQUIRE(SuccessFrom(mdb_open(txn, NULL, 0, &dbi)));
THEN("the transaction can be committed") {
REQUIRE(SuccessFrom(mdb_txn_commit(txn)));
}
}
}
mdb_dbi_close(env, dbi);
mdb_env_close(env);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment