blob: 01e2a138a8df3ed0bee362eae7fbcb5b050054c9 (
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/*******************************************************************************
* Copyright (C) 2015, Max Hohenegger <eclipse@hohenegger.eu>
*
* 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.gitflow;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.Iterator;
import org.eclipse.egit.gitflow.GitFlowRepository;
import org.eclipse.egit.gitflow.ui.internal.UIText;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Tests for the Team->Gitflow->Feature Finish action with squash option
*/
@RunWith(SWTBotJunit4ClassRunner.class)
public class FeatureFinishSquashHandlerTest extends
AbstractFeatureFinishHandlerTest {
private static final String SQUASHED_COMMENT_SUMMARY = "Hello World";
@Test
public void testFeatureFinishSquash() throws Exception {
int expectedCommitCount = 2;
init();
setContentAddAndCommit("bar");
expectedCommitCount++;
createFeature(FEATURE_NAME);
RevCommit commit1 = setContentAddAndCommit("commit 1");
expectedCommitCount++;
RevCommit commit2 = setContentAddAndCommit("commit 2");
expectedCommitCount++;
checkoutBranch(DEVELOP);
checkoutFeature(FEATURE_NAME);
finishFeature();
expectedCommitCount--;
RevCommit developHead = new GitFlowRepository(repository).findHead();
assertNotEquals(developHead, commit1);
assertNotEquals(developHead, commit2);
assertEquals(expectedCommitCount, countCommits());
assertTrue(developHead.getFullMessage().startsWith(
SQUASHED_COMMENT_SUMMARY));
}
private int countCommits() throws GitAPIException, NoHeadException,
IOException {
Iterable<RevCommit> commits = Git.wrap(repository).log().all().call();
Iterator<RevCommit> iterator = commits.iterator();
int count = 0;
while (iterator.hasNext()) {
iterator.next();
count++;
}
return count;
}
@Override
protected void preFinish() {
int firstLine = 0;
bot.styledText().selectLine(firstLine);
bot.styledText().typeText(SQUASHED_COMMENT_SUMMARY);
bot.button("OK").click();
}
@Override
protected void selectOptions() {
bot.checkBox(UIText.FinishFeatureDialog_squashCheck).click();
}
}
|