blob: b370f20fa580d668a1b2b5d1d5f77825f267252c [file] [log] [blame]
Alexander Afanasyevb0c78ea2014-04-15 18:12:04 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (C) 2014 Regents of the University of California.
4 * See COPYING for copyright and distribution information.
5 */
6
7#ifndef REPO_TESTS_SQLITE_FIXTURE_HPP
8#define REPO_TESTS_SQLITE_FIXTURE_HPP
9
10#include "../storage/sqlite/sqlite-handle.hpp"
11
12#include <boost/filesystem.hpp>
13#include <boost/test/unit_test.hpp>
14
15namespace repo {
16namespace tests {
17
18class SqliteFixture
19{
20public:
21 SqliteFixture()
22 {
23 boost::filesystem::path testPath("unittestdb");
24 boost::filesystem::file_status testPathStatus = boost::filesystem::status(testPath);
25 if (!boost::filesystem::is_directory(testPathStatus)) {
26 if (!boost::filesystem::create_directory(boost::filesystem::path(testPath))) {
27 BOOST_FAIL("Cannot create unittestdb folder");
28 }
29 }
30 handle = new SqliteHandle("unittestdb");
31 }
32
33 ~SqliteFixture()
34 {
35 delete handle;
36 boost::filesystem::remove_all(boost::filesystem::path("unittestdb"));
37 }
38
39public:
40 SqliteHandle* handle;
41};
42
43} // namespace tests
44} // namespace repo
45
46#endif // REPO_TESTS_SQLITE_FIXTURE_HPP