-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from axonivy/more-tests
Add more tests
- Loading branch information
Showing
9 changed files
with
308 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/test/java/io/ivyteam/devops/pullrequest/TestPullRequestRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package io.ivyteam.devops.pullrequest; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Map; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
import io.ivyteam.devops.db.Database; | ||
import io.ivyteam.devops.repo.Repo; | ||
import io.ivyteam.devops.repo.RepoRepository; | ||
import io.ivyteam.devops.user.UserRepository; | ||
|
||
class TestPullRequestRepository { | ||
|
||
@TempDir | ||
Path tempDir; | ||
|
||
RepoRepository repos; | ||
|
||
PullRequestRepository prs; | ||
|
||
PullRequest PR = PullRequest | ||
.create() | ||
.title("PR-1") | ||
.user("alex") | ||
.repository("axonivy/test") | ||
.id(1) | ||
.branchName("master") | ||
.build(); | ||
|
||
@BeforeEach | ||
void beforeEach() { | ||
var db = new Database(tempDir.resolve("test.db")); | ||
var users = new UserRepository(db); | ||
repos = new RepoRepository(db); | ||
repos.create(Repo.create().name("axonivy/test").build()); | ||
prs = new PullRequestRepository(db, users); | ||
} | ||
|
||
@Test | ||
void all_empty() { | ||
assertThat(prs.all()).isEmpty(); | ||
} | ||
|
||
@Test | ||
void findByUser_empty() { | ||
assertThat(prs.findByUser("suter")).isEmpty(); | ||
} | ||
|
||
@Test | ||
void findByUser() { | ||
prs.create(PR); | ||
assertThat(prs.findByUser("alex")).containsExactly(PR); | ||
} | ||
|
||
@Test | ||
void findByRepository_empty() { | ||
assertThat(prs.findByRepository("gotham")).isEmpty(); | ||
} | ||
|
||
@Test | ||
void findByRepository() { | ||
prs.create(PR); | ||
assertThat(prs.findByRepository("axonivy/test")).containsExactly(PR); | ||
} | ||
|
||
@Test | ||
void delete() { | ||
prs.create(PR); | ||
prs.delete(PR); | ||
assertThat(prs.all()).isEmpty(); | ||
} | ||
|
||
@Test | ||
void countByRepo() { | ||
prs.create(PR); | ||
assertThat(prs.countByRepo()).containsExactly(Map.entry("axonivy/test", 1L)); | ||
} | ||
|
||
@Test | ||
void create() { | ||
prs.create(PR); | ||
assertThat(prs.all()).containsExactly(PR); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters