File indexing completed on 2024-05-12 15:51:08
0001 // SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu> 0002 // SPDX-License-Identifier: LGPL-2.0-or-later 0003 0004 #include "database.h" 0005 #include <QtTest/QtTest> 0006 #include <qstringliteral.h> 0007 0008 class TestDatabase : public Database 0009 { 0010 public: 0011 TestDatabase() 0012 : Database(QLatin1String("./test.db")) 0013 { 0014 } 0015 }; 0016 0017 class DatabaseTest : public QObject 0018 { 0019 Q_OBJECT 0020 0021 private Q_SLOTS: 0022 void initTestCase() 0023 { 0024 } 0025 0026 void testModel() 0027 { 0028 TestDatabase db; 0029 0030 QFile file; 0031 file.setFileName(QLatin1String(DATA_DIR) + QLatin1Char('/') + QStringLiteral("book-metadata.json")); 0032 file.open(QIODevice::ReadOnly); 0033 0034 QVERIFY(db.addBook(QStringLiteral("mybook.epub"), QString::fromUtf8(file.readAll()))); 0035 QVERIFY(db.addBook(QStringLiteral("mybook.epub"), QString::fromUtf8(file.readAll()))); 0036 0037 QCOMPARE(db.rowCount(), 1); 0038 } 0039 }; 0040 0041 QTEST_MAIN(DatabaseTest) 0042 #include "databasetest.moc"