mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-02 04:56:58 +00:00
Check the exception message.
This makes the tests a bit more strict by also checking the message returned by the what() function. This shows that some of the tests are out of sync with which errors they check for. I will hopefully fix this in another pass. Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
This commit is contained in:
@@ -26,43 +26,49 @@
|
||||
|
||||
using namespace sstables;
|
||||
|
||||
static future<> broken_sst(sstring dir, unsigned long generation) {
|
||||
static future<> broken_sst(sstring dir, unsigned long generation, sstring msg) {
|
||||
// Using an empty schema for this function, which is only about loading
|
||||
// a malformed component and checking that it fails.
|
||||
auto s = make_lw_shared(schema({}, "ks", "cf", {}, {}, {}, {}, utf8_type));
|
||||
auto sst = std::make_unique<sstable>(s, dir, generation, la, big);
|
||||
auto fut = sst->load();
|
||||
return std::move(fut).then_wrapped([sst = std::move(sst)] (future<> f) mutable {
|
||||
return std::move(fut).then_wrapped([sst = std::move(sst), msg = std::move(msg)] (future<> f) mutable {
|
||||
try {
|
||||
f.get();
|
||||
BOOST_FAIL("expecting exception");
|
||||
} catch (malformed_sstable_exception& e) {
|
||||
// ok
|
||||
BOOST_REQUIRE_EQUAL(sstring(e.what()), msg);
|
||||
}
|
||||
return make_ready_future<>();
|
||||
});
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(empty_toc) {
|
||||
return broken_sst("tests/sstables/badtoc", 1);
|
||||
return broken_sst("tests/sstables/badtoc", 1,
|
||||
"Empty TOC in sstable tests/sstables/badtoc/la-1-big-TOC.txt");
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(alien_toc) {
|
||||
return broken_sst("tests/sstables/badtoc", 2);
|
||||
return broken_sst("tests/sstables/badtoc", 2,
|
||||
"tests/sstables/badtoc/la-2-big-Statistics.db: file not found");
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(truncated_toc) {
|
||||
return broken_sst("tests/sstables/badtoc", 3);
|
||||
return broken_sst("tests/sstables/badtoc", 3,
|
||||
"tests/sstables/badtoc/la-3-big-Statistics.db: file not found");
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(wrong_format_toc) {
|
||||
return broken_sst("tests/sstables/badtoc", 4);
|
||||
return broken_sst("tests/sstables/badtoc", 4,
|
||||
"tests/sstables/badtoc/la-4-big-TOC.txt: file not found");
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(compression_truncated) {
|
||||
return broken_sst("tests/sstables/badcompression", 1);
|
||||
return broken_sst("tests/sstables/badcompression", 1,
|
||||
"tests/sstables/badcompression/la-1-big-Statistics.db: file not found");
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(compression_bytes_flipped) {
|
||||
return broken_sst("tests/sstables/badcompression", 2);
|
||||
return broken_sst("tests/sstables/badcompression", 2,
|
||||
"tests/sstables/badcompression/la-2-big-Statistics.db: file not found");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user