Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
ddit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jack MacLauchlan CS2015
ddit
Commits
c229e3a4
Commit
c229e3a4
authored
6 years ago
by
Jack MacLauchlan CS2015
Browse files
Options
Downloads
Patches
Plain Diff
issue repo tests
parent
73d71f20
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/git/IssueRepoTests.java
+38
-10
38 additions, 10 deletions
src/test/java/git/IssueRepoTests.java
with
38 additions
and
10 deletions
src/test/java/git/IssueRepoTests.java
+
38
−
10
View file @
c229e3a4
package
git
;
import
issueData.Issue
;
import
org.apache.commons.io.FileUtils
;
import
org.eclipse.jgit.api.Git
;
import
org.eclipse.jgit.api.errors.GitAPIException
;
...
...
@@ -55,28 +56,57 @@ class IssueRepoTests {
}
@Test
void
testIssueBranchExistInvalidRepo
()
{
void
testGetIssues
()
throws
IOException
{
populateRepoWithFakeData
();
IssueRepo
issueRepo
=
new
IssueRepo
();
a
ss
ertThrows
(
IOException
.
class
,
()
->
{
issueRepo
.
s
et
GitDir
(
"/!"
);
}
);
i
ss
ueRepo
.
setGitDir
(
path
.
toAbsolutePath
()
+
"/.git"
);
assertEquals
(
2
,
issueRepo
.
g
et
Issues
().
size
()
);
}
@Test
void
testGetNicknames
()
throws
IOException
{
populateRepoWithFakeData
();
IssueRepo
issueRepo
=
new
IssueRepo
();
issueRepo
.
setGitDir
(
path
.
toAbsolutePath
()
+
"/.git"
);
assertEquals
(
1
,
issueRepo
.
getNicknames
().
getIssueNicknames
().
size
());
}
@Test
void
test
GetIssues
()
throws
IOException
{
void
test
WriteRepo
()
throws
IOException
{
populateRepoWithFakeData
();
IssueRepo
issueRepo
=
new
IssueRepo
();
issueRepo
.
setGitDir
(
path
.
toAbsolutePath
()
+
"/.git"
);
assertEquals
(
2
,
issueRepo
.
getIssues
().
size
());
issueRepo
.
getIssues
().
get
(
0
).
setStatus
(
false
);
assertTrue
(
issueRepo
.
writeRepo
(
"test writerepo"
));
}
@Test
void
testGet
Nicknames
()
throws
IOException
{
void
testGet
IssueWithHash
()
throws
IOException
{
populateRepoWithFakeData
();
IssueRepo
issueRepo
=
new
IssueRepo
();
issueRepo
.
setGitDir
(
path
.
toAbsolutePath
()
+
"/.git"
);
assertEquals
(
1
,
issueRepo
.
getNicknames
().
getIssueNicknames
().
size
());
assertTrue
(
issueRepo
.
getIssue
(
"7a37cedc949c7be72767e9b7b008f33ba4b5136ff4a8bd4c6b00ca69b6ce51db"
).
isPresent
());
}
@Test
void
testGetIssueWithNickname
()
throws
IOException
{
populateRepoWithFakeData
();
IssueRepo
issueRepo
=
new
IssueRepo
();
issueRepo
.
setGitDir
(
path
.
toAbsolutePath
()
+
"/.git"
);
assertTrue
(
issueRepo
.
getIssue
(
"issue"
).
isPresent
());
}
@Test
void
testTwoIssueSameHash
()
throws
IOException
{
populateRepoWithFakeData
();
IssueRepo
issueRepo
=
new
IssueRepo
();
issueRepo
.
setGitDir
(
path
.
toAbsolutePath
()
+
"/.git"
);
Issue
duplciate
=
new
Issue
();
duplciate
.
setHash
(
"7a37cedc949c7be72767e9b7b008f33ba4b5136ff4a8bd4c6b00ca69b6ce51db"
);
issueRepo
.
getIssues
().
add
(
duplciate
);
assertThrows
(
IllegalStateException
.
class
,
()
->
issueRepo
.
getIssue
(
"7a37cedc949c7be72767e9b7b008f33ba4b5136ff4a8bd4c6b00ca69b6ce51db"
));
}
private
void
populateRepoWithFakeData
()
{
...
...
@@ -104,7 +134,5 @@ class IssueRepoTests {
assertEquals
(
"Issue (orphan) branch created"
,
commit
.
getFullMessage
());
walk
.
dispose
();
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment