| 315 | } |
| 316 | |
| 317 | void GitInitTest::testBranch(const QString& newBranch) |
| 318 | { |
| 319 | //Already tested, so I assume that it works |
| 320 | const QUrl baseUrl = QUrl::fromLocalFile(gitTest_BaseDir()); |
| 321 | QString oldBranch = runSynchronously(m_plugin->currentBranch(baseUrl)).toString(); |
| 322 | |
| 323 | VcsRevision rev; |
| 324 | rev.setRevisionValue(oldBranch, KDevelop::VcsRevision::GlobalNumber); |
| 325 | VcsJob* j = m_plugin->branch(baseUrl, rev, newBranch); |
| 326 | VERIFYJOB(j); |
| 327 | QVERIFY(runSynchronously(m_plugin->branches(baseUrl)).toStringList().contains(newBranch)); |
| 328 | |
| 329 | // switch branch |
| 330 | j = m_plugin->switchBranch(baseUrl, newBranch); |
| 331 | VERIFYJOB(j); |
| 332 | QCOMPARE(runSynchronously(m_plugin->currentBranch(baseUrl)).toString(), newBranch); |
| 333 | |
| 334 | // get into detached head state |
| 335 | j = m_plugin->switchBranch(baseUrl, QStringLiteral("HEAD~1")); |
| 336 | VERIFYJOB(j); |
| 337 | QCOMPARE(runSynchronously(m_plugin->currentBranch(baseUrl)).toString(), QString()); |
| 338 | |
| 339 | // switch back |
| 340 | j = m_plugin->switchBranch(baseUrl, newBranch); |
| 341 | VERIFYJOB(j); |
| 342 | QCOMPARE(runSynchronously(m_plugin->currentBranch(baseUrl)).toString(), newBranch); |
| 343 | |
| 344 | j = m_plugin->deleteBranch(baseUrl, oldBranch); |
| 345 | VERIFYJOB(j); |
| 346 | QVERIFY(!runSynchronously(m_plugin->branches(baseUrl)).toStringList().contains(oldBranch)); |
| 347 | |
| 348 | // Test that we can't delete branch on which we currently are |
| 349 | j = m_plugin->deleteBranch(baseUrl, newBranch); |
| 350 | VERIFYJOBFAILURE(j); |
| 351 | QVERIFY(runSynchronously(m_plugin->branches(baseUrl)).toStringList().contains(newBranch)); |
| 352 | |
| 353 | // Test branching off HEAD |
| 354 | rev = KDevelop::VcsRevision::createSpecialRevision(KDevelop::VcsRevision::Head); |
| 355 | j = m_plugin->branch(baseUrl, rev, newBranch+QStringLiteral("-new")); |
| 356 | VERIFYJOB(j); |
| 357 | QVERIFY(runSynchronously(m_plugin->branches(baseUrl)).toStringList().contains(newBranch+QStringLiteral("-new"))); |
| 358 | } |
| 359 | |
| 360 | void GitInitTest::testMerge() |
| 361 | { |
nothing calls this directly
no test coverage detected