Skip to content

Commit

Permalink
Refactor test/s3store to make check_new_account_info() reusable.
Browse files Browse the repository at this point in the history
(cherry picked from commit 2f597e1)
  • Loading branch information
qris committed Jul 23, 2017
1 parent bcaffc0 commit 897f429
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/common/Test.h
Expand Up @@ -10,6 +10,9 @@
#ifndef TEST__H
#define TEST__H

// for printf:
#include <stdio.h>

#include <cstring>
#include <list>
#include <map>
Expand Down
15 changes: 14 additions & 1 deletion test/s3store/tests3store.cpp
Expand Up @@ -70,14 +70,26 @@ bool kill_running_daemons()
TEST_THAT(kill_running_daemons()); \
TEARDOWN();

bool check_new_account_info();

bool test_create_account_with_account_control()
{
SETUP_TEST_S3SIMULATOR();

std::auto_ptr<Configuration> config = load_config_file(DEFAULT_BBACKUPD_CONFIG_FILE,
BackupDaemonConfigVerify);
TEST_LINE_OR(config.get(), "Failed to load configuration, aborting", FAIL);

S3BackupAccountControl control(*config);
control.CreateAccount("test", 1000, 2000);
TEST_THAT(check_new_account_info());

TEARDOWN_TEST_S3SIMULATOR();
}

bool check_new_account_info()
{
int old_failure_count_local = num_failures;

FileStream fs("testfiles/store/subdir/" S3_INFO_FILE_NAME);
std::auto_ptr<BackupStoreInfo> info = BackupStoreInfo::Load(fs, fs.GetFileName(),
Expand Down Expand Up @@ -105,7 +117,8 @@ bool test_create_account_with_account_control()
BackupStoreDirectory root_dir(root_stream);
TEST_EQUAL(0, root_dir.GetNumberOfEntries());

TEARDOWN_TEST_S3SIMULATOR();
// Return true if no new failures.
return (old_failure_count_local == num_failures);
}

int test(int argc, const char *argv[])
Expand Down

0 comments on commit 897f429

Please sign in to comment.