blob: c7e04bb6ab1120c7d5e7007526e21cbbd781cf30 [file] [log] [blame]
Zhiyi Zhangae123bf2017-04-14 12:24:53 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Zhiyi Zhang42d992d2019-07-07 16:46:50 -07002/*
3 * Copyright (c) 2013-2019 Regents of the University of California.
Zhiyi Zhangae123bf2017-04-14 12:24:53 -07004 *
Zhiyi Zhang42d992d2019-07-07 16:46:50 -07005 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Zhiyi Zhangae123bf2017-04-14 12:24:53 -07006 *
Zhiyi Zhang42d992d2019-07-07 16:46:50 -07007 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070010 *
Zhiyi Zhang42d992d2019-07-07 16:46:50 -070011 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070012 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
Zhiyi Zhang42d992d2019-07-07 16:46:50 -070013 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070014 *
Zhiyi Zhang42d992d2019-07-07 16:46:50 -070015 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070018 *
Zhiyi Zhang42d992d2019-07-07 16:46:50 -070019 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070020 */
21
22#ifndef NDNCERT_TESTS_DATABASE_FIXTURE_HPP
23#define NDNCERT_TESTS_DATABASE_FIXTURE_HPP
24
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070025#include "identity-management-fixture.hpp"
26#include <boost/filesystem.hpp>
27
28namespace ndn {
29namespace ndncert {
30namespace tests {
31
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070032class DatabaseFixture : public IdentityManagementTimeFixture
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070033{
34public:
35 DatabaseFixture()
36 {
Zhiyi Zhang42d992d2019-07-07 16:46:50 -070037 auto parentDir = boost::filesystem::path(getenv("TEST_HOME"));
38 if (!boost::filesystem::exists(parentDir)) {
39 boost::filesystem::create_directory(parentDir);
40 }
41 dbDir = parentDir / ".ndncert";
42 if (!boost::filesystem::exists(dbDir)) {
43 boost::filesystem::create_directory(dbDir);
44 }
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070045 }
46
47 ~DatabaseFixture()
48 {
49 boost::filesystem::remove_all(dbDir);
50 }
51
52public:
53 boost::filesystem::path dbDir;
54};
55
56} // namespace tests
57} // namespace ndncert
58} // namespace ndn
59
60#endif // NDNCERT_TESTS_DATABASE_FIXTURE_HPP