diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-08-24 09:32:27 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-08-25 10:43:41 -0700 |
commit | 6eed3155e6a84f1b27b5340b45d6deb801fee42d (patch) | |
tree | d22bc1723f296880327e607bf73f15d24b8ef74a | |
parent | eb205c1b090b94f4812358c8835065491d149c6b (diff) | |
download | subsurface-6eed3155e6a84f1b27b5340b45d6deb801fee42d.tar.gz |
Add simple test for git storage
This just makes sure that writing data to git storage and reading it back
gives you the same result. Without the fixed generation of initial dive
site UUIDs this fails.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/testgitstorage.cpp | 37 | ||||
-rw-r--r-- | tests/testgitstorage.h | 13 |
3 files changed, 51 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a2270bf7..da98a218d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -571,6 +571,7 @@ if(NOT NO_TESTS) TEST(TestProfile testprofile.cpp) TEST(TestGpsCoords testgpscoords.cpp) TEST(TestParse testparse.cpp) + TEST(TestGitStorage testgitstorage.cpp) TEST(TestPlan testplan.cpp) endif() diff --git a/tests/testgitstorage.cpp b/tests/testgitstorage.cpp new file mode 100644 index 000000000..abb4b2c59 --- /dev/null +++ b/tests/testgitstorage.cpp @@ -0,0 +1,37 @@ +#include "testgitstorage.h" +#include "dive.h" +#include "divelist.h" +#include "file.h" +#include "git2.h" +#include <QDir> +#include <QTextStream> + +void TestGitStorage::testGitStorageLocal() +{ + // test writing and reading back from local git storage + git_repository *repo; + git_libgit2_init(); + QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/SampleDivesV2.ssrf"), 0); + QString testDirName("./gittest"); + QDir testDir(testDirName); + QCOMPARE(testDir.removeRecursively(), true); + QCOMPARE(QDir().mkdir(testDirName), true); + QCOMPARE(git_repository_init(&repo, qPrintable(testDirName), false), 0); + QCOMPARE(save_dives(qPrintable(testDirName + "[test]")), 0); + QCOMPARE(save_dives("./SampleDivesV3.ssrf"), 0); + clear_dive_file_data(); + QCOMPARE(parse_file(qPrintable(testDirName + "[test]")), 0); + QCOMPARE(save_dives("./SampleDivesV3viagit.ssrf"), 0); + QFile org("./SampleDivesV3.ssrf"); + org.open(QFile::ReadOnly); + QFile out("./SampleDivesV3viagit.ssrf"); + out.open(QFile::ReadOnly); + QTextStream orgS(&org); + QTextStream outS(&out); + QString readin = orgS.readAll(); + QString written = outS.readAll(); + QCOMPARE(readin, written); + clear_dive_file_data(); +} + +QTEST_MAIN(TestGitStorage) diff --git a/tests/testgitstorage.h b/tests/testgitstorage.h new file mode 100644 index 000000000..b182d4a22 --- /dev/null +++ b/tests/testgitstorage.h @@ -0,0 +1,13 @@ +#ifndef TESTGITSTORAGE_H +#define TESTGITSTORAGE_H + +#include <QTest> + +class TestGitStorage : public QObject +{ + Q_OBJECT +private slots: + void testGitStorageLocal(); +}; + +#endif // TESTGITSTORAGE_H |