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 package com.jcabi.github.mock;
31
32 import com.jcabi.github.Coordinates;
33 import java.io.IOException;
34 import java.util.Arrays;
35 import java.util.Collections;
36 import org.hamcrest.MatcherAssert;
37 import org.hamcrest.Matchers;
38 import org.junit.Test;
39
40
41
42
43
44
45 public final class MkRepoCommitsTest {
46
47
48
49
50
51 @Test
52 public void returnIterator() throws IOException {
53 final String user = "testuser1";
54 MatcherAssert.assertThat(
55 new MkRepoCommits(
56 new MkStorage.InFile(),
57 user,
58 new Coordinates.Simple(user, "testrepo1")
59 ).iterate(Collections.<String, String>emptyMap()),
60 Matchers.notNullValue()
61 );
62 }
63
64
65
66
67
68 @Test
69 public void getCommit() throws IOException {
70 final String user = "testuser2";
71 final String sha = "6dcb09b5b57875f334f61aebed695e2e4193db5e";
72 MatcherAssert.assertThat(
73 new MkRepoCommits(
74 new MkStorage.InFile(),
75 user,
76 new Coordinates.Simple(user, "testrepo2")
77 ).get(sha),
78 Matchers.notNullValue()
79 );
80 }
81
82
83
84
85
86 @Test
87 public void canCompare() throws IOException {
88 final String user = "testuser3";
89 MatcherAssert.assertThat(
90 new MkRepoCommits(
91 new MkStorage.InFile(),
92 user,
93 new Coordinates.Simple(user, "testrepo3")
94 ).compare("5339b8e35b", "9b2e6efde9"),
95 Matchers.notNullValue()
96 );
97 }
98
99
100
101
102
103 @Test
104 public void canCompareAsDiffFormat() throws Exception {
105 final String user = "testuser4";
106 final String base = "c034abc";
107 final String head = "a0ed832";
108 MatcherAssert.assertThat(
109 new MkRepoCommits(
110 new MkStorage.InFile(),
111 user,
112 new Coordinates.Simple(user, "testrepo4")
113 ).diff(base, head),
114 Matchers.stringContainsInOrder(Arrays.asList(base, head))
115 );
116 }
117
118
119
120
121
122 @Test
123 public void canCompareAsPatch() throws Exception {
124 final String user = "testuser5";
125 final String head = "9b2e6e7de9";
126 MatcherAssert.assertThat(
127 new MkRepoCommits(
128 new MkStorage.InFile(), user,
129 new Coordinates.Simple(user, "testrepo5")
130 ).patch("5c39b8e35b", head),
131 Matchers.stringContainsInOrder(
132 Arrays.asList(
133 head, "From:", "Date:", "Subject:", "files changed",
134 "insertions", "deletions"
135 )
136 )
137 );
138 }
139 }