Make TestGitStorage::testGitStorageLocal parametrizable

Make use of QTest "Data Driven Testing",
allowing to test multiple repo base path values.

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
This commit is contained in:
Jeremie Guichard 2017-02-24 14:02:32 +07:00 committed by Dirk Hohndel
parent 56d31c9c1b
commit 5640a6a839
2 changed files with 9 additions and 1 deletions

View file

@ -59,13 +59,20 @@ void TestGitStorage::testSetup()
QCOMPARE(localCacheDirectory.removeRecursively(), true); QCOMPARE(localCacheDirectory.removeRecursively(), true);
} }
void TestGitStorage::testGitStorageLocal_data()
{
// test different path we may encounter (since storage depends on user name)
QTest::addColumn<QString>("testDirName");
QTest::newRow("ASCII path") << "./gittest";
}
void TestGitStorage::testGitStorageLocal() void TestGitStorage::testGitStorageLocal()
{ {
// test writing and reading back from local git storage // test writing and reading back from local git storage
git_repository *repo; git_repository *repo;
git_libgit2_init(); git_libgit2_init();
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf"), 0); QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf"), 0);
QString testDirName("./gittest"); QFETCH(QString, testDirName);
QDir testDir(testDirName); QDir testDir(testDirName);
QCOMPARE(testDir.removeRecursively(), true); QCOMPARE(testDir.removeRecursively(), true);
QCOMPARE(QDir().mkdir(testDirName), true); QCOMPARE(QDir().mkdir(testDirName), true);

View file

@ -8,6 +8,7 @@ class TestGitStorage : public QObject
Q_OBJECT Q_OBJECT
private slots: private slots:
void testSetup(); void testSetup();
void testGitStorageLocal_data();
void testGitStorageLocal(); void testGitStorageLocal();
void testGitStorageCloud(); void testGitStorageCloud();
void testGitStorageCloudOfflineSync(); void testGitStorageCloudOfflineSync();