-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
6 changed files
with
140 additions
and
16 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
65 changes: 65 additions & 0 deletions
65
src/test/java/dev/iakunin/codexiabot/bot/ForksUpTransactionIntegrationTest.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,65 @@ | ||
package dev.iakunin.codexiabot.bot; | ||
|
||
import com.github.database.rider.core.api.dataset.DataSet; | ||
import com.github.database.rider.core.api.dataset.ExpectedDataSet; | ||
import dev.iakunin.codexiabot.AbstractIntegrationTest; | ||
import dev.iakunin.codexiabot.CodexiaBotApplication; | ||
import dev.iakunin.codexiabot.codexia.CodexiaModule; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.context.annotation.Primary; | ||
|
||
@SpringBootTest(classes = { | ||
AbstractIntegrationTest.TestConfig.class, | ||
ForksUpTransactionIntegrationTest.TestConfig.class, | ||
}) | ||
public class ForksUpTransactionIntegrationTest extends AbstractIntegrationTest { | ||
|
||
private static final String EXCEPTION_MESSAGE = "Some error"; | ||
|
||
@Qualifier("forksUp") | ||
@Autowired | ||
private Up forksUp; | ||
|
||
@Test | ||
@DataSet( | ||
value = "db-rider/bot/forks-up-transaction/initial/transactionRollback.yml", | ||
cleanBefore = true, cleanAfter = true | ||
) | ||
@ExpectedDataSet("db-rider/bot/forks-up-transaction/expected/transactionRollback.yml") | ||
public void transactionRollback() { | ||
final RuntimeException exception = assertThrows(RuntimeException.class, this.forksUp::run); | ||
|
||
assertEquals( | ||
ForksUpTransactionIntegrationTest.EXCEPTION_MESSAGE, | ||
exception.getMessage() | ||
); | ||
} | ||
|
||
@Configuration | ||
@Import(CodexiaBotApplication.class) | ||
static class TestConfig { | ||
@Bean | ||
@Primary | ||
public CodexiaModule codexiaModule() { | ||
final CodexiaModule mock = Mockito.mock(CodexiaModule.class); | ||
Mockito.doThrow( | ||
new RuntimeException( | ||
ForksUpTransactionIntegrationTest.EXCEPTION_MESSAGE | ||
) | ||
) | ||
.when(mock) | ||
.sendMeta(Mockito.any()); | ||
|
||
return mock; | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/test/resources/db-rider/bot/forks-up-transaction/expected/transactionRollback.yml
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,3 @@ | ||
forks_up_result: [] | ||
|
||
codexia_review: [] |
44 changes: 44 additions & 0 deletions
44
src/test/resources/db-rider/bot/forks-up-transaction/initial/transactionRollback.yml
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,44 @@ | ||
github_repo: | ||
- | ||
id: 1 | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
external_id: "150713223" | ||
full_name: "test-project1/test-repo1" | ||
|
||
codexia_project: | ||
- | ||
id: 5 | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
external_id: 12 | ||
coordinates: "test-project1/test-repo1" | ||
author: "some-first-author" | ||
deleted: null | ||
project_created_at: "2019-12-20 12:01:02" | ||
|
||
github_repo_source: | ||
- | ||
id: 1 | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
github_repo_id: 1 | ||
source: "CODEXIA" | ||
external_id: "12" | ||
|
||
github_repo_stat: | ||
- | ||
id: 1 | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
github_repo_id: 1 | ||
type: "GITHUB_API" | ||
stat: '{"type": "GITHUB_API", "forks": 402}' | ||
created_at: "2020-02-11 10:06:16.123456" | ||
- | ||
id: 3 | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
github_repo_id: 1 | ||
type: "GITHUB_API" | ||
stat: '{"type": "GITHUB_API", "forks": 459}' | ||
created_at: "2020-02-16 18:46:09.652645" | ||
|
||
forks_up_result: [] | ||
|
||
codexia_review: [] |
717a95f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
6-4d9a1ad5
disappeared fromsrc/main/java/dev/iakunin/codexiabot/bot/StarsUp.java
, that's why I closed #25. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.