* it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Tocc is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 *  along with Tocc.  If not, see <http://www.gnu.org/licenses/>.
 */


#include <catch.hpp>

#include "libtocc/front_end/manager.h"
#include "libtocc/common/database_exceptions.h"

/*
 * Test cases for scenarios that must throw exception.
 */
TEST_CASE("front_end: assign tag wrong tests")
{
  libtocc::Manager manager("/tmp/");

  REQUIRE_THROWS_AS(manager.assign_tags("f89ac3e", "author:Unknown"),
                    libtocc::DatabaseScriptExecutionError);

}
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Tocc is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 *  along with Tocc.  If not, see <http://www.gnu.org/licenses/>.
 */


#include <catch.hpp>

#include "libtocc/front_end/manager.h"
#include "libtocc/common/database_exceptions.h"


TEST_CASE("Manager::get tests")
{
  libtocc::Manager manager("/tmp/tocctests/");

  SECTION("file not found error")
  {
    REQUIRE_THROWS_AS(
        manager.get_file_info("e31b6da"),
        libtocc::DatabaseScriptLogicalError);
  }
}
예제 #3
0
#include "libtocc/front_end/manager.h"
#include "libtocc/front_end/file_info.h"
#include "libtocc/common/file_system_exceptions.h"



TEST_CASE("front_end: file import")
{
  // Creating a file to import.
  std::ofstream file_stream;
  file_stream.open("/tmp/tocctests/tocc_test_file_to_import_2");
  file_stream << "some data...";
  file_stream.close();

  // Creating an instance of the manager.
  libtocc::Manager manager("/tmp/tocctests/");

  SECTION("Importing a file with no property")
  {
    // Importing the file with no property.
    libtocc::FileInfo test_file =
        manager.import_file("/tmp/tocctests/tocc_test_file_to_import_2");
    // Checking if it's OK.
    REQUIRE(strcmp(test_file.get_title(), "tocc_test_file_to_import_2") == 0);
    REQUIRE(strcmp(test_file.get_traditional_path(), "") == 0);
    REQUIRE(test_file.get_tags().size() == 0);

    // Getting the file again.
    libtocc::FileInfo fetched_test_file = manager.get_file_info(test_file.get_id());
    // Checking if it's OK.
    REQUIRE(strcmp(fetched_test_file.get_title(), "tocc_test_file_to_import_2") == 0);