Warning, file /libraries/libqgit2/tests/Init.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 
0002 #include "TestHelpers.h"
0003 
0004 #include "qgitrepository.h"
0005 #include <QDir>
0006 #include <QPointer>
0007 
0008 
0009 using namespace LibQGit2;
0010 
0011 
0012 class TestInit : public TestBase
0013 {
0014     Q_OBJECT
0015 
0016 public:
0017     TestInit();
0018     ~TestInit();
0019 
0020 private slots:
0021 
0022     void initTestCase();
0023     void cleanupTestCase();
0024 
0025     void init();
0026     void initBare();
0027 
0028 private:
0029     QPointer<Repository> repo;
0030 
0031     const QString repoPath;
0032 };
0033 
0034 
0035 
0036 TestInit::TestInit() :
0037     repo(0),
0038     repoPath(QString(VALUE_TO_STR(TEST_DIR)) + "/repo")
0039 {
0040 }
0041 
0042 
0043 void TestInit::initTestCase()
0044 {
0045     TestBase::initTestCase();
0046 
0047     QVERIFY(!repo);
0048 
0049     // Create a new repository object
0050     repo = new LibQGit2::Repository();
0051 
0052     QVERIFY(repo);
0053 }
0054 
0055 void TestInit::cleanupTestCase()
0056 {
0057     QVERIFY(repo);
0058     delete repo;
0059     QVERIFY(!repo);
0060 
0061     TestBase::cleanupTestCase();
0062 }
0063 
0064 void TestInit::init()
0065 {
0066     QVERIFY(removeDir(repoPath));
0067     QVERIFY(!QDir(repoPath).exists());
0068 
0069     QDir().mkdir(repoPath);
0070     QVERIFY(QDir(repoPath).exists());
0071 
0072     try {
0073         repo->init(repoPath, false);
0074     } catch (const LibQGit2::Exception& ex) {
0075         QFAIL(ex.what());
0076     }
0077 
0078     QVERIFY(QDir(repoPath).exists());
0079     QVERIFY(QFile(repoPath + "/.git").exists());
0080     QVERIFY(QFile(repoPath + "/.git/HEAD").exists());
0081 }
0082 
0083 
0084 void TestInit::initBare()
0085 {
0086     QVERIFY(removeDir(repoPath));
0087     QVERIFY(!QDir(repoPath).exists());
0088 
0089     QDir().mkdir(repoPath);
0090     QVERIFY(QDir(repoPath).exists());
0091 
0092     try {
0093         repo->init(repoPath, true);
0094     } catch (const LibQGit2::Exception& ex) {
0095         QFAIL(ex.what());
0096     }
0097 
0098     QVERIFY(QDir(repoPath).exists());
0099     QVERIFY(!QFile(repoPath + "/.git").exists());
0100     QVERIFY(QFile(repoPath + "/HEAD").exists());
0101 }
0102 
0103 
0104 TestInit::~TestInit()
0105 {
0106     delete repo;
0107 }
0108 
0109 
0110 QTEST_MAIN(TestInit);
0111 
0112 #include "Init.moc"