diff options
author | Chris Wilson <chris+github@qwirx.com> | 2014-10-31 22:09:36 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2014-10-31 22:09:36 +0000 |
commit | d2e2721815a38db704ce66c662a54b77da147484 (patch) | |
tree | 7bb69ab6e8417caf32a8ef3c343939c0df310b74 /test | |
parent | 6d52b312e556356030edd6ec5904faa63f5b9778 (diff) |
Add a test that temporary and permanent refcount dbs are independent
Conflicts:
test/backupstore/testbackupstore.cpp
Diffstat (limited to 'test')
-rw-r--r-- | test/backupstore/testbackupstore.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/backupstore/testbackupstore.cpp b/test/backupstore/testbackupstore.cpp index 8fe76473..d17ed56f 100644 --- a/test/backupstore/testbackupstore.cpp +++ b/test/backupstore/testbackupstore.cpp @@ -781,6 +781,45 @@ int64_t create_directory(BackupProtocolCallable& protocol, int64_t create_file(BackupProtocolCallable& protocol, int64_t subdirid, const std::string& remote_filename = ""); +bool run_housekeeping_and_check_account(BackupProtocolLocal2& protocol) +{ + protocol.QueryFinished(); + bool check_account_status; + TEST_THAT(check_account_status = run_housekeeping_and_check_account()); + bool check_refcount_status; + TEST_THAT(check_refcount_status = check_reference_counts()); + protocol.Reopen(); + return check_account_status & check_refcount_status; +} + +bool test_temporary_refcount_db_is_independent() +{ + SETUP(); + + std::auto_ptr<BackupStoreAccountDatabase> apAccounts( + BackupStoreAccountDatabase::Read("testfiles/accounts.txt")); + std::auto_ptr<BackupStoreRefCountDatabase> temp( + BackupStoreRefCountDatabase::Create( + apAccounts->GetEntry(0x1234567))); + std::auto_ptr<BackupStoreRefCountDatabase> perm( + BackupStoreRefCountDatabase::Load( + apAccounts->GetEntry(0x1234567), + false // readonly + )); + + TEST_CHECK_THROWS(temp->GetRefCount(2), + BackupStoreException, UnknownObjectRefCountRequested); + TEST_CHECK_THROWS(perm->GetRefCount(2), + BackupStoreException, UnknownObjectRefCountRequested); + temp->AddReference(2); + TEST_EQUAL(1, temp->GetRefCount(2)); + TEST_CHECK_THROWS(perm->GetRefCount(2), + BackupStoreException, UnknownObjectRefCountRequested); + temp->Discard(); + + return teardown_test_backupstore(); +} + bool test_server_housekeeping() { SETUP(); @@ -3039,6 +3078,7 @@ int test(int argc, const char *argv[]) } TEST_THAT(test_filename_encoding()); + TEST_THAT(test_temporary_refcount_db_is_independent()); TEST_THAT(test_bbstoreaccounts_create()); TEST_THAT(test_bbstoreaccounts_delete()); TEST_THAT(test_backupstore_directory()); |