test/unittests/uploader.cpp
// SetUp & TearDown create a temp directory for the upload, after the test it is deleted.
// these functions are called for each test individually.
SetUp & TearDown create a temp directory for the upload, after the test it is deleted.
these functions are called for each test individually.
SetUp & TearDown create a temp directory for the upload after the test it is deleted . these functions are called for each test individually .
void UploaderTest::SetUp() {
    Configuration::loadFromDefaultPaths();
    time_t now = time(nullptr);
    UserDB::init("sqlite", ":memory:", std::make_unique<UserDBTestClock_Uploader>(&now), 0);
    Configuration::loadFromString("[uploader]\ndirectory=\""+ temp_dir_name + "\"");
    upl_dir = Configuration::get<std::string>("uploader.directory");
    const std::string username = "dummy";
    const std::string password = "12345";
    const std::string userpermission = "upload";
    auto user = UserDB::createUser(username, "realname", "email", password);
    user->addPermission(userpermission);
    auto session = UserDB::createSession(username, password);
    sessiontoken = session->getSessiontoken();
    userID = user->getUserIDString();
    setenv("REQUEST_METHOD", "POST", true);
    setenv("CONTENT_TYPE", "multipart/mixed", true);
}
void UploaderTest :: SetUp ( ) { Configuration :: loadFromDefaultPaths ( ) ; time_t now = time ( nullptr ) ; UserDB :: init ( " " , " " , std :: make_unique < UserDBTestClock_Uploader > ( & now ) , 0 ) ; Configuration :: loadFromString ( " \n \" " + temp_dir_name + " \" " ) ; upl_dir = Configuration :: get < std :: string > ( " " ) ; const std :: string username = " " ; const std :: string password = " " ; const std :: string userpermission = " " ; auto user = UserDB :: createUser ( username , " " , " " , password ) ; user -> addPermission ( userpermission ) ; auto session = UserDB :: createSession ( username , password ) ; sessiontoken = session -> getSessiontoken ( ) ; userID = user -> getUserIDString ( ) ; setenv ( " " , " " , true ) ; setenv ( " " , " " , true ) ; }
SetUp & TearDown create a temp directory for the upload, after the test it is deleted.
SetUp & TearDown create a temp directory for the upload after the test it is deleted .
//change upload dir parameter to a test directory // Create a user and session //set env variables for the http request