summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2014-08-15 22:47:30 +0000
committerChris Wilson <chris+github@qwirx.com>2014-08-15 22:47:30 +0000
commit81afb5a2d918f2de818516520db792c2adeb5879 (patch)
treeb2779effb404e59430f2fc409f6240e9c9930eaf
parent59b5045c4005dd85658de4f613237e21e897f6b2 (diff)
Add a TEST_PROTOCOL_ERROR_OR assertion.
Similar to TEST_COMMAND_RETURNS_ERROR_OR, but allows any command or sequence to cause the error, without direct access to the command message. Refactor so that TEST_COMMAND_RETURNS_ERROR_OR calls TEST_PROTOCOL_ERROR_OR to make the assertion on the last error seen by the protocol.
-rw-r--r--lib/backupstore/StoreTestUtils.h9
-rw-r--r--test/bbackupd/testbbackupd.cpp1
2 files changed, 7 insertions, 3 deletions
diff --git a/lib/backupstore/StoreTestUtils.h b/lib/backupstore/StoreTestUtils.h
index 39013422..7ef2ce28 100644
--- a/lib/backupstore/StoreTestUtils.h
+++ b/lib/backupstore/StoreTestUtils.h
@@ -80,10 +80,8 @@ bool create_account(int soft, int hard);
//! Deletes the standard test account, for testing behaviour with no account.
bool delete_account();
-#define TEST_COMMAND_RETURNS_ERROR_OR(protocol, command, error, or_statements) \
+#define TEST_PROTOCOL_ERROR_OR(protocol, error, or_statements) \
{ \
- TEST_CHECK_THROWS_OR(protocol . command, ConnectionException, \
- Conn_Protocol_UnexpectedReply, or_statements); \
int type, subtype; \
protocol.GetLastError(type, subtype); \
if (type == BackupProtocolError::ErrorType) \
@@ -103,6 +101,11 @@ bool delete_account();
} \
}
+#define TEST_COMMAND_RETURNS_ERROR_OR(protocol, command, error, or_statements) \
+ TEST_CHECK_THROWS_OR(protocol . command, ConnectionException, \
+ Protocol_UnexpectedReply, or_statements); \
+ TEST_PROTOCOL_ERROR_OR(protocol, error, or_statements)
+
#define TEST_COMMAND_RETURNS_ERROR(protocol, command, error) \
TEST_COMMAND_RETURNS_ERROR_OR(protocol, command, error,)
diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp
index c25c38a0..d09132cc 100644
--- a/test/bbackupd/testbbackupd.cpp
+++ b/test/bbackupd/testbbackupd.cpp
@@ -883,6 +883,7 @@ int test_bbackupd()
TEST_CHECK_THROWS(ReadDirectory(*client, 0x12345678),
ConnectionException,
Protocol_UnexpectedReply);
+ TEST_PROTOCOL_ERROR_OR(*client, Err_DoesNotExist,);
}
client->QueryFinished();