1
2
3
4
5
6
7
8
9
10 package org.eclipse.jgit.pgm;
11
12 import static org.junit.Assert.assertEquals;
13
14 import org.eclipse.jgit.lib.CLIRepositoryTestCase;
15 import org.junit.Test;
16
17 public class CommitTest extends CLIRepositoryTestCase {
18
19 @Test
20 public void testCommitPath() throws Exception {
21 writeTrashFile("a", "a");
22 writeTrashFile("b", "a");
23 String result = toString(execute("git add a"));
24 assertEquals("", result);
25
26 result = toString(execute("git status -- a"));
27 assertEquals(toString("On branch master", "Changes to be committed:",
28 "new file: a"), result);
29
30 result = toString(execute("git status -- b"));
31 assertEquals(toString("On branch master", "Untracked files:", "b"),
32 result);
33
34 result = toString(execute("git commit a -m 'added a'"));
35 assertEquals(
36 "[master 8cb3ef7e5171aaee1792df6302a5a0cd30425f7a] added a",
37 result);
38
39 result = toString(execute("git status -- a"));
40 assertEquals("On branch master", result);
41
42 result = toString(execute("git status -- b"));
43 assertEquals(toString("On branch master", "Untracked files:", "b"),
44 result);
45 }
46
47 @Test
48 public void testCommitAll() throws Exception {
49 writeTrashFile("a", "a");
50 writeTrashFile("b", "a");
51 String result = toString(execute("git add a b"));
52 assertEquals("", result);
53
54 result = toString(execute("git status -- a b"));
55 assertEquals(toString("On branch master", "Changes to be committed:",
56 "new file: a", "new file: b"), result);
57
58 result = toString(execute("git commit -m 'added a b'"));
59 assertEquals(
60 "[master 3c93fa8e3a28ee26690498be78016edcb3a38c73] added a b",
61 result);
62
63 result = toString(execute("git status -- a b"));
64 assertEquals("On branch master", result);
65 }
66
67 }