Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame^] | 1 | /* -*- 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 | |
| 15 | namespace repo { |
| 16 | namespace tests { |
| 17 | |
| 18 | class SqliteFixture |
| 19 | { |
| 20 | public: |
| 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 | |
| 39 | public: |
| 40 | SqliteHandle* handle; |
| 41 | }; |
| 42 | |
| 43 | } // namespace tests |
| 44 | } // namespace repo |
| 45 | |
| 46 | #endif // REPO_TESTS_SQLITE_FIXTURE_HPP |