Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 5d688da5cec6e6aa4c5ec892726632af2ed0f78a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*******************************************************************************
 * Copyright (C) 2011, Dariusz Luksza <dariusz@luksza.org>
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.eclipse.egit.ui.internal.synchronize.model;

import static org.eclipse.jgit.lib.Constants.HEAD;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import java.io.File;

import org.eclipse.egit.core.synchronize.dto.GitSynchronizeData;
import org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet;
import org.eclipse.jgit.lib.Repository;
import org.junit.Before;
import org.junit.Test;

public class GitModelRootTest extends GitModelTestCase {

	private static Repository repo1, repo2;

	@Before
	public void setupEnvironment() throws Exception {
		File repoFile = createProjectAndCommitToRepository(REPO1);
		repo1 = lookupRepository(repoFile);

		repoFile = createProjectAndCommitToRepository(REPO2);
		repo2 = lookupRepository(repoFile);
	}

	@Test
	public void shouldIgnoreEmptyRepositories() throws Exception {
		// given
		touchAndSubmit("second commit");
		GitSynchronizeDataSet gsds = new GitSynchronizeDataSet();
		gsds.add(new GitSynchronizeData(repo1, HEAD, HEAD + "^1", false));
		gsds.add(new GitSynchronizeData(repo2, HEAD, HEAD, false));

		// when
		GitModelRoot root = new GitModelRoot(gsds);

		// then
		assertThat(Integer.valueOf(root.getChildren().length),
				is(Integer.valueOf(1)));
	}

}

Back to the top