Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDariusz Luksza2010-08-12 17:22:16 -0400
committerDariusz Luksza2010-08-12 17:37:16 -0400
commit51fd48888c37b71e5bfa9b4084c805dc7bb5d745 (patch)
treedf63c7b2fbf633631c43f8185fb1aaf7f230b762 /org.eclipse.egit.core.test
parent057173ac27c0724152f91869133dfa163d07fc6a (diff)
downloadegit-51fd48888c37b71e5bfa9b4084c805dc7bb5d745.tar.gz
egit-51fd48888c37b71e5bfa9b4084c805dc7bb5d745.tar.xz
egit-51fd48888c37b71e5bfa9b4084c805dc7bb5d745.zip
Fix for bug in GitResourceVariantComparator
When comparing local folder with folder that wasn't exist remotly GitResourceVaraintCompare return that both resources are equal. I've added additional condition for resource existence. Change-Id: Ie8b97fffd1237723afce6aed3c116b280694b3ba Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
Diffstat (limited to 'org.eclipse.egit.core.test')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java24
1 files changed, 22 insertions, 2 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java
index 31b6b4a35..a0048adf2 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java
@@ -36,6 +36,7 @@ import org.eclipse.egit.core.test.GitTestCase;
import org.eclipse.egit.core.test.TestRepository;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.treewalk.TreeWalk;
@@ -99,6 +100,25 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
verify(local);
}
+ @Test
+ @SuppressWarnings("boxing")
+ public void shouldReturnFalseWhenRemoteDoesNotExist2() throws Exception{
+ // when
+ GitResourceVariantComparator grvc = new GitResourceVariantComparator(
+ null);
+
+ // given
+ IResource local = createMock(IResource.class);
+ expect(local.exists()).andReturn(false);
+ replay(local);
+ IResourceVariant remote = new GitFolderResourceVariant(repo,
+ ObjectId.zeroId(), "./");
+
+ // then
+ assertFalse(grvc.compare(local, remote));
+ verify(local);
+ }
+
/**
* It is possible to have a local file that has same name as a remote
* folder. In some cases that two resources can be compared. In this case
@@ -142,7 +162,7 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
IPath localPath = createMock(IPath.class);
replay(localPath);
IContainer local = createMock(IContainer.class);
- expect(local.exists()).andReturn(true);
+ expect(local.exists()).andReturn(true).times(2);
expect(local.getFullPath()).andReturn(localPath);
replay(local);
@@ -183,7 +203,7 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
IPath iPath = new Path(File.separator + path);
IContainer local = createMock(IContainer.class);
- expect(local.exists()).andReturn(true);
+ expect(local.exists()).andReturn(true).times(2);
expect(local.getFullPath()).andReturn(iPath).anyTimes();
replay(local);

Back to the top