Skip to content

Commit 6103ba2

Browse files
author
TheSnoozer
committed
add some basic tests (mainly copied from GitCommitIdMojoIntegrationTest but adjusted to the core-plugin)
1 parent 72d7f04 commit 6103ba2

4 files changed

Lines changed: 1996 additions & 0 deletions

File tree

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@
231231
<version>1.1.1</version>
232232
<scope>test</scope>
233233
</dependency>
234+
<dependency>
235+
<groupId>com.github.stefanbirkner</groupId>
236+
<artifactId>system-rules</artifactId>
237+
<version>1.19.0</version>
238+
<scope>test</scope>
239+
</dependency>
234240
<!-- slf4j is a dependency of jgit, this suppresses slf4j's warning during testing when we mock jgit stuff -->
235241
<dependency>
236242
<groupId>org.slf4j</groupId>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* This file is part of git-commit-id-plugin-core by Konrad 'ktoso' Malawski <konrad.malawski@java.pl>
3+
*
4+
* git-commit-id-plugin-core is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* git-commit-id-plugin-core is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with git-commit-id-plugin-core. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package pl.project13.core;
19+
20+
21+
import javax.annotation.Nonnull;
22+
import java.io.File;
23+
24+
public enum AvailableGitTestRepo {
25+
WITH_ONE_COMMIT("src/test/resources/_git_one_commit"),
26+
WITH_ONE_COMMIT_DIRTY("src/test/resources/_git_one_commit_dirty"),
27+
GIT_COMMIT_ID("src/test/resources/_git_of_git_commit_id"),
28+
GIT_WITH_NO_CHANGES("src/test/resources/_git_with_no_changes"),
29+
ON_A_TAG("src/test/resources/_git_on_a_tag"),
30+
/**
31+
* <pre>
32+
* $ lg
33+
* * b6a73ed - (HEAD, master) third addition (32 hours ago) <p>Konrad Malawski</p>
34+
* * d37a598 - (newest-tag, lightweight-tag) second line (32 hours ago) <p>Konrad Malawski</p>
35+
* * 9597545 - (annotated-tag) initial commit (32 hours ago) <p>Konrad Malawski</p>
36+
* </pre>
37+
*
38+
* Where the <b>newest-tag</b> was created latest:
39+
* <pre>
40+
* $ tag -v newest-tag
41+
* object d37a598a7a98531ad1375966642c6b1263129436
42+
* tagger Konrad Malawski <p>konrad.malawski@project13.pl</p> 1346017608 +0200
43+
*
44+
* $ tag -v annotated-tag
45+
* object 95975455ef2b1af048f2926b9ba7fb804e22171b
46+
* tagger Konrad Malawski <p>konrad.malawski@project13.pl</p> 1345901561 +0200
47+
* </pre>
48+
*/
49+
WITH_COMMIT_THAT_HAS_TWO_TAGS("src/test/resources/_git_with_commit_that_has_two_tags"),
50+
ON_A_TAG_DIRTY("src/test/resources/_git_on_a_tag_dirty"),
51+
WITH_SUBMODULES("src/test/resources/_git_with_submodules"),
52+
/**
53+
* <pre>
54+
* b6a73ed - (HEAD, master) third addition (4 minutes ago) <p>Konrad Malawski</p>
55+
* d37a598 - (lightweight-tag) second line (6 minutes ago) <p>Konrad Malawski</p>
56+
* 9597545 - (annotated-tag) initial commit (6 minutes ago) <p>Konrad Malawski</p>
57+
* </pre>
58+
*/
59+
WITH_LIGHTWEIGHT_TAG_BEFORE_ANNOTATED_TAG("src/test/resources/_git_lightweight_tag_before_annotated_tag"),
60+
/**
61+
* <pre>
62+
* * 9cb810e - Change in tag - Fri, 29 Nov 2013 10:39:31 +0100 (tag: test_tag, branch: test)
63+
* | * 2343428 - Moved master - Fri, 29 Nov 2013 10:38:34 +0100 (HEAD, branch: master)
64+
* |/
65+
* * e3d159d - Added readme - Fri, 29 Nov 2013 10:38:02 +0100
66+
* </pre>
67+
*/
68+
WITH_TAG_ON_DIFFERENT_BRANCH("src/test/resources/_git_with_tag_on_different_branch"),
69+
WITH_ONE_COMMIT_WITH_SPECIAL_CHARACTERS("src/test/resources/_git_one_commit_with_umlaut"),
70+
/**
71+
* <pre>
72+
* b0c6d28b3b83bf7b905321bae67d9ca4c75a203f 2015-06-04 00:50:18 +0200 (HEAD, master)
73+
* 0e3495783c56589213ee5f2ae8900e2dc1b776c4 2015-06-03 23:59:10 +0200 (tag: v2.0)
74+
* f830b5f85cad3d33ba50d04c3d1454e1ae469057 2015-06-03 23:57:53 +0200 (tag: v1.0)
75+
* </pre>
76+
*/
77+
WITH_THREE_COMMITS_AND_TWO_TAGS_CURRENTLY_ON_COMMIT_WITHOUT_TAG("src/test/resources/_git_three_commits_and_two_tags_currently_on_commit_without_tag"),
78+
// TODO: Why do the tests get stuck when we use .git??
79+
MAVEN_GIT_COMMIT_ID_PLUGIN("src/test/resources/_git_one_commit_with_umlaut")
80+
;
81+
82+
private String dir;
83+
84+
AvailableGitTestRepo(String dir) {
85+
this.dir = dir;
86+
}
87+
88+
@Nonnull
89+
public File getDir() {
90+
return new File(dir);
91+
}
92+
}

0 commit comments

Comments
 (0)