@Test public void shouldNotBeAheadAfterPush() throws Exception { String fileName = "a.txt"; String fileContent = "*****@*****.**"; File file = testRepository.createFile(fileName, fileContent); testRepository.addAndCommit(file, "adding a file"); testRepository.addRemoteTo(REPO2_REMOTE_NAME, testRepository2.getRepository()); assertTrue(EGitUtils.isAhead(testRepository.getRepository(), REPO2_REMOTE_NAME, null)); EGitUtils.pushForce(REPO2_REMOTE_NAME, testRepository.getRepository(), null); assertFalse(EGitUtils.isAhead(testRepository.getRepository(), REPO2_REMOTE_NAME, null)); }
@Test public void fileAddedToCloneIsInRemoteAfterPush() throws Exception { String fileName = "c.txt"; String fileContent = "*****@*****.**"; File file = testRepositoryClone.createFile(fileName, fileContent); testRepositoryClone.addAndCommit(file, "adding a file"); testRepositoryClone.addRemoteTo(REPO2_REMOTE_NAME, testRepository2.getRepository()); EGitUtils.pushForce(REPO2_REMOTE_NAME, testRepositoryClone.getRepository(), null); // repo2 must contain file added to clone testUtils.assertRepositoryContainsFilesWithContent( testRepository2.getRepository(), fileName, fileContent); }
@Test public void forcedPushRemovesFileInRemote() throws Exception { String fileName = "a.txt"; String fileContent = "*****@*****.**"; File file = testRepository.createFile(fileName, fileContent); testRepository.addAndCommit(file, "adding a file"); File file2 = testRepository2.createFile("b.txt", "bingobongo"); testRepository2.addAndCommit(file2, "adding a file"); testRepository.addRemoteTo(REPO2_REMOTE_NAME, testRepository2.getRepository()); EGitUtils.pushForce(REPO2_REMOTE_NAME, testRepository.getRepository(), null); // repo2 mustn't contain "b.txt" testUtils.assertRepositoryMisses(testRepository2.getRepository(), file2.getName()); // repo2 must contain "a.txt" testUtils.assertRepositoryContainsFilesWithContent( testRepository2.getRepository(), fileName, fileContent); }