summaryrefslogtreecommitdiffstats
path: root/tests/testgitstorage.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-08-18 15:06:15 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-08-23 10:17:12 -0700
commitd815e0c9476ef62e6b84fb28ce48ab7cddefe77e (patch)
tree997b938f8080518d339797aae4630eb66b81e204 /tests/testgitstorage.cpp
parentecb64d7e3e3c6c875defc9dc4aab01c65ccddf8a (diff)
downloadsubsurface-d815e0c9476ef62e6b84fb28ce48ab7cddefe77e.tar.gz
Parse: pass dive_table argument to parse_file()
To enable undo of divelog-importing it is crucial that parse_file() can parse into arbitrary dive tables. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'tests/testgitstorage.cpp')
-rw-r--r--tests/testgitstorage.cpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/tests/testgitstorage.cpp b/tests/testgitstorage.cpp
index 1448c60ac..43c5ed03a 100644
--- a/tests/testgitstorage.cpp
+++ b/tests/testgitstorage.cpp
@@ -88,7 +88,7 @@ void TestGitStorage::testGitStorageLocal()
// test writing and reading back from local git storage
git_repository *repo;
git_libgit2_init();
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf", &dive_table), 0);
QFETCH(QString, testDirName);
QFETCH(QString, prefixRead);
QFETCH(QString, prefixWrite);
@@ -101,7 +101,7 @@ void TestGitStorage::testGitStorageLocal()
QCOMPARE(save_dives(qPrintable(repoNameWrite + "[test]")), 0);
QCOMPARE(save_dives("./SampleDivesV3.ssrf"), 0);
clear_dive_file_data();
- QCOMPARE(parse_file(qPrintable(repoNameRead + "[test]")), 0);
+ QCOMPARE(parse_file(qPrintable(repoNameRead + "[test]"), &dive_table), 0);
QCOMPARE(save_dives("./SampleDivesV3viagit.ssrf"), 0);
QFile org("./SampleDivesV3.ssrf");
org.open(QFile::ReadOnly);
@@ -120,10 +120,10 @@ void TestGitStorage::testGitStorageCloud()
// connect to the ssrftest repository on the cloud server
// and repeat the same test as before with the local git storage
QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]");
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf", &dive_table), 0);
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
clear_dive_file_data();
- QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0);
QCOMPARE(save_dives("./SampleDivesV3viacloud.ssrf"), 0);
QFile org("./SampleDivesV3.ssrf");
org.open(QFile::ReadOnly);
@@ -144,8 +144,8 @@ void TestGitStorage::testGitStorageCloudOfflineSync()
QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org"));
QString localCacheRepo = localCacheDir + "[ssrftest@hohndel.org]";
// read the local repo from the previous test and add dive 10
- QCOMPARE(parse_file(qPrintable(localCacheRepo)), 0);
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test10.xml"), 0);
+ QCOMPARE(parse_file(qPrintable(localCacheRepo), &dive_table), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test10.xml", &dive_table), 0);
// calling process_dive() sorts the table, but calling it with
// is_imported == true causes it to try to update the window title... let's not do that
process_dives(false, false);
@@ -154,7 +154,7 @@ void TestGitStorage::testGitStorageCloudOfflineSync()
QCOMPARE(save_dives("./SampleDivesV3plus10local.ssrf"), 0);
clear_dive_file_data();
// open the cloud storage and compare
- QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0);
QCOMPARE(save_dives("./SampleDivesV3plus10viacloud.ssrf"), 0);
QFile org("./SampleDivesV3plus10local.ssrf");
org.open(QFile::ReadOnly);
@@ -172,7 +172,7 @@ void TestGitStorage::testGitStorageCloudOfflineSync()
QDir localCacheDirectorySave(localCacheDir + "save");
QCOMPARE(localCacheDirectorySave.removeRecursively(), true);
QCOMPARE(localCacheDirectory.rename(localCacheDir, localCacheDir + "save"), true);
- QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0);
QCOMPARE(save_dives("./SampleDivesV3plus10fromcloud.ssrf"), 0);
org.close();
org.open(QFile::ReadOnly);
@@ -193,15 +193,15 @@ void TestGitStorage::testGitStorageCloudMerge()
QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]");
QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org"));
QString localCacheRepoSave = localCacheDir + "save[ssrftest@hohndel.org]";
- QCOMPARE(parse_file(qPrintable(localCacheRepoSave)), 0);
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml"), 0);
+ QCOMPARE(parse_file(qPrintable(localCacheRepoSave), &dive_table), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml", &dive_table), 0);
process_dives(false, false);
QCOMPARE(save_dives(qPrintable(localCacheRepoSave)), 0);
clear_dive_file_data();
// now we open the cloud storage repo and add a different dive to it
- QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml"), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml", &dive_table), 0);
process_dives(false, false);
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
clear_dive_file_data();
@@ -212,13 +212,13 @@ void TestGitStorage::testGitStorageCloudMerge()
QCOMPARE(localCacheDirectory.removeRecursively(), true);
QDir localCacheDirectorySave(localCacheDir + "save");
QCOMPARE(localCacheDirectory.rename(localCacheDir + "save", localCacheDir), true);
- QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0);
QCOMPARE(save_dives("./SampleDivesV3plus10-11-12-merged.ssrf"), 0);
clear_dive_file_data();
- QCOMPARE(parse_file("./SampleDivesV3plus10local.ssrf"), 0);
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml"), 0);
+ QCOMPARE(parse_file("./SampleDivesV3plus10local.ssrf", &dive_table), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml", &dive_table), 0);
process_dives(false, false);
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml"), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml", &dive_table), 0);
process_dives(false, false);
QCOMPARE(save_dives("./SampleDivesV3plus10-11-12.ssrf"), 0);
QFile org("./SampleDivesV3plus10-11-12-merged.ssrf");
@@ -240,7 +240,7 @@ void TestGitStorage::testGitStorageCloudMerge2()
QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]");
QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org"));
QString localCacheRepo = localCacheDir + "[ssrftest@hohndel.org]";
- QCOMPARE(parse_file(qPrintable(localCacheRepo)), 0);
+ QCOMPARE(parse_file(qPrintable(localCacheRepo), &dive_table), 0);
process_dives(false, false);
struct dive *dive = get_dive(1);
delete_single_dive(1);
@@ -256,7 +256,7 @@ void TestGitStorage::testGitStorageCloudMerge2()
QCOMPARE(localCacheDirectory.rename(localCacheDir, localCacheDir + "save"), true);
}
// now we open the cloud storage repo and modify that first dive
- QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0);
process_dives(false, false);
dive = get_dive(1);
QVERIFY(dive != NULL);
@@ -272,7 +272,7 @@ void TestGitStorage::testGitStorageCloudMerge2()
QCOMPARE(localCacheDirectory.removeRecursively(), true);
QCOMPARE(localCacheDirectorySave.rename(localCacheDir + "save", localCacheDir), true);
- QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0);
QCOMPARE(save_dives("./SampleDivesMinus1-merged.ssrf"), 0);
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
QFile org("./SampleDivesMinus1-merged.ssrf");
@@ -296,7 +296,7 @@ void TestGitStorage::testGitStorageCloudMerge3()
QString cloudTestRepo("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org[ssrftest@hohndel.org]");
QString localCacheDir(get_local_dir("https://cloud.subsurface-divelog.org/git/ssrftest@hohndel.org", "ssrftest@hohndel.org"));
QString localCacheRepo = localCacheDir + "[ssrftest@hohndel.org]";
- QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0);
process_dives(false, false);
struct dive *dive = get_dive(0);
QVERIFY(dive != 0);
@@ -308,7 +308,7 @@ void TestGitStorage::testGitStorageCloudMerge3()
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
clear_dive_file_data();
- QCOMPARE(parse_file(qPrintable(localCacheRepo)), 0);
+ QCOMPARE(parse_file(qPrintable(localCacheRepo), &dive_table), 0);
process_dives(false, false);
dive = get_dive(0);
dive->notes = strdup("Create multi line dive notes\nDifferent line 2 and removed 3-5\n\nThat should be enough");
@@ -327,7 +327,7 @@ void TestGitStorage::testGitStorageCloudMerge3()
QCOMPARE(localCacheDirectory.rename(localCacheDir, localCacheDir + "save"), true);
}
// now we open the cloud storage repo and modify those first dive notes differently
- QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0);
process_dives(false, false);
dive = get_dive(0);
dive->notes = strdup("Completely different dive notes\nBut also multi line");
@@ -345,7 +345,7 @@ void TestGitStorage::testGitStorageCloudMerge3()
QCOMPARE(localCacheDirectory.removeRecursively(), true);
QCOMPARE(localCacheDirectorySave.rename(localCacheDir + "save", localCacheDir), true);
- QCOMPARE(parse_file(qPrintable(cloudTestRepo)), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table), 0);
QCOMPARE(save_dives("./SampleDivesMerge3.ssrf"), 0);
// we are not trying to compare this to a pre-determined result... what this test
// checks is that there are no parsing errors with the merge