-
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.
- Loading branch information
Showing
10 changed files
with
279 additions
and
1 deletion.
There are no files selected for viewing
92 changes: 91 additions & 1 deletion
92
src/test/java/dev/iakunin/codexiabot/github/cron/stat/GithubIntegrationTest.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 |
---|---|---|
@@ -1,13 +1,103 @@ | ||
package dev.iakunin.codexiabot.github.cron.stat; | ||
|
||
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.util.WireMockServer; | ||
import dev.iakunin.codexiabot.util.wiremock.Response; | ||
import dev.iakunin.codexiabot.util.wiremock.Stub; | ||
import lombok.SneakyThrows; | ||
import org.cactoos.io.ResourceOf; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.kohsuke.github.GitHub; | ||
import org.kohsuke.github.GitHubBuilder; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
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.http.HttpStatus; | ||
|
||
@SpringBootTest(classes = { | ||
AbstractIntegrationTest.TestConfig.class, | ||
GithubIntegrationTest.TestConfig.class, | ||
}) | ||
public class GithubIntegrationTest extends AbstractIntegrationTest { | ||
|
||
@Autowired | ||
private Github github; | ||
|
||
// @todo #10 Implement GithubIntegrationTest | ||
@Test | ||
@DataSet( | ||
value = "db-rider/github/cron/stat/github/initial/emptyDatabase.yml", | ||
cleanBefore = true, cleanAfter = true | ||
) | ||
@ExpectedDataSet("db-rider/github/cron/stat/github/expected/emptyDatabase.yml") | ||
public void emptyDatabase() { | ||
github.run(); | ||
} | ||
|
||
@Test | ||
@DataSet( | ||
value = "db-rider/github/cron/stat/github/initial/notCodexiaSource.yml", | ||
cleanBefore = true, cleanAfter = true | ||
) | ||
@ExpectedDataSet("db-rider/github/cron/stat/github/expected/notCodexiaSource.yml") | ||
public void notCodexiaSource() { | ||
github.run(); | ||
} | ||
|
||
@Test | ||
@DataSet( | ||
value = "db-rider/github/cron/stat/github/initial/happyPath.yml", | ||
cleanBefore = true, cleanAfter = true | ||
) | ||
@ExpectedDataSet("db-rider/github/cron/stat/github/expected/happyPath.yml") | ||
public void oneWithoutGithubRepo() { | ||
WireMockServer.stub( | ||
new Stub( | ||
"/repos/instaloader/instaloader", | ||
new ResourceOf("wiremock/github/cron/stat/github/instaloader.json") | ||
) | ||
); | ||
|
||
github.run(); | ||
} | ||
|
||
@Test | ||
@DataSet( | ||
value = "db-rider/github/cron/stat/github/initial/githubIoException.yml", | ||
cleanBefore = true, cleanAfter = true | ||
) | ||
@ExpectedDataSet("db-rider/github/cron/stat/github/expected/githubIoException.yml") | ||
public void githubIoException() { | ||
WireMockServer.stub( | ||
new Stub( | ||
"/repos/instaloader/instaloader", | ||
new Response(HttpStatus.INTERNAL_SERVER_ERROR.value()) | ||
) | ||
); | ||
|
||
github.run(); | ||
} | ||
|
||
@AfterEach | ||
void after() { | ||
WireMockServer.getInstance().resetAll(); | ||
} | ||
|
||
@Configuration | ||
@Import(CodexiaBotApplication.class) | ||
static class TestConfig { | ||
@SneakyThrows | ||
@Bean | ||
public GitHub gitHub() { | ||
return new GitHubBuilder() | ||
.withEndpoint( | ||
WireMockServer.getInstance().baseUrl() | ||
).build(); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/test/resources/db-rider/github/cron/stat/github/expected/emptyDatabase.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 @@ | ||
github_repo_stat: [] |
1 change: 1 addition & 0 deletions
1
src/test/resources/db-rider/github/cron/stat/github/expected/githubIoException.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 @@ | ||
github_repo_stat: [] |
5 changes: 5 additions & 0 deletions
5
src/test/resources/db-rider/github/cron/stat/github/expected/happyPath.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,5 @@ | ||
github_repo_stat: | ||
- | ||
github_repo_id: 1 | ||
type: "GITHUB_API" | ||
stat: '{"description":"Download pictures (or videos) along with their captions and other metadata from Instagram.","pushedAt":[2020,5,11,18,27,23],"language":"Python","homepage":"https://instaloader.github.io/","forks":281,"watchers":1561,"stars":1561,"type":"GITHUB_API"}' |
1 change: 1 addition & 0 deletions
1
src/test/resources/db-rider/github/cron/stat/github/expected/notCodexiaSource.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 @@ | ||
github_repo_stat: [] |
6 changes: 6 additions & 0 deletions
6
src/test/resources/db-rider/github/cron/stat/github/initial/emptyDatabase.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,6 @@ | ||
github_repo: [] | ||
|
||
github_repo_source: [] | ||
|
||
github_repo_stat: [] | ||
|
17 changes: 17 additions & 0 deletions
17
src/test/resources/db-rider/github/cron/stat/github/initial/githubIoException.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,17 @@ | ||
github_repo: | ||
- | ||
id: 1 | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
external_id: 61200117 | ||
full_name: instaloader/instaloader | ||
html_url: https://github.com/instaloader/instaloader | ||
repo_created_at: 2019-08-14 04:42:36 | ||
|
||
github_repo_source: | ||
- | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
github_repo_id: 1 | ||
source: "CODEXIA" | ||
external_id: "2222" | ||
|
||
github_repo_stat: [] |
17 changes: 17 additions & 0 deletions
17
src/test/resources/db-rider/github/cron/stat/github/initial/happyPath.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,17 @@ | ||
github_repo: | ||
- | ||
id: 1 | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
external_id: 61200117 | ||
full_name: instaloader/instaloader | ||
html_url: https://github.com/instaloader/instaloader | ||
repo_created_at: 2019-08-14 04:42:36 | ||
|
||
github_repo_source: | ||
- | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
github_repo_id: 1 | ||
source: "CODEXIA" | ||
external_id: "2222" | ||
|
||
github_repo_stat: [] |
17 changes: 17 additions & 0 deletions
17
src/test/resources/db-rider/github/cron/stat/github/initial/notCodexiaSource.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,17 @@ | ||
github_repo: | ||
- | ||
id: 1 | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
external_id: 202275988 | ||
full_name: test1/test1 | ||
html_url: https://github.com/test1/test1 | ||
repo_created_at: 2019-08-14 04:42:36 | ||
|
||
github_repo_source: | ||
- | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
github_repo_id: 1 | ||
source: "HACKERNEWS" | ||
external_id: "2222" | ||
|
||
github_repo_stat: [] |
123 changes: 123 additions & 0 deletions
123
src/test/resources/wiremock/github/cron/stat/github/instaloader.json
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,123 @@ | ||
{ | ||
"id": 61200117, | ||
"node_id": "MDEwOlJlcG9zaXRvcnk2MTIwMDExNw==", | ||
"name": "instaloader", | ||
"full_name": "instaloader/instaloader", | ||
"private": false, | ||
"owner": { | ||
"login": "instaloader", | ||
"id": 37333353, | ||
"node_id": "MDEyOk9yZ2FuaXphdGlvbjM3MzMzMzUz", | ||
"avatar_url": "https://avatars0.githubusercontent.com/u/37333353?v=4", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/instaloader", | ||
"html_url": "https://github.com/instaloader", | ||
"followers_url": "https://api.github.com/users/instaloader/followers", | ||
"following_url": "https://api.github.com/users/instaloader/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/instaloader/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/instaloader/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/instaloader/subscriptions", | ||
"organizations_url": "https://api.github.com/users/instaloader/orgs", | ||
"repos_url": "https://api.github.com/users/instaloader/repos", | ||
"events_url": "https://api.github.com/users/instaloader/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/instaloader/received_events", | ||
"type": "Organization", | ||
"site_admin": false | ||
}, | ||
"html_url": "https://github.com/instaloader/instaloader", | ||
"description": "Download pictures (or videos) along with their captions and other metadata from Instagram.", | ||
"fork": false, | ||
"url": "https://api.github.com/repos/instaloader/instaloader", | ||
"forks_url": "https://api.github.com/repos/instaloader/instaloader/forks", | ||
"keys_url": "https://api.github.com/repos/instaloader/instaloader/keys{/key_id}", | ||
"collaborators_url": "https://api.github.com/repos/instaloader/instaloader/collaborators{/collaborator}", | ||
"teams_url": "https://api.github.com/repos/instaloader/instaloader/teams", | ||
"hooks_url": "https://api.github.com/repos/instaloader/instaloader/hooks", | ||
"issue_events_url": "https://api.github.com/repos/instaloader/instaloader/issues/events{/number}", | ||
"events_url": "https://api.github.com/repos/instaloader/instaloader/events", | ||
"assignees_url": "https://api.github.com/repos/instaloader/instaloader/assignees{/user}", | ||
"branches_url": "https://api.github.com/repos/instaloader/instaloader/branches{/branch}", | ||
"tags_url": "https://api.github.com/repos/instaloader/instaloader/tags", | ||
"blobs_url": "https://api.github.com/repos/instaloader/instaloader/git/blobs{/sha}", | ||
"git_tags_url": "https://api.github.com/repos/instaloader/instaloader/git/tags{/sha}", | ||
"git_refs_url": "https://api.github.com/repos/instaloader/instaloader/git/refs{/sha}", | ||
"trees_url": "https://api.github.com/repos/instaloader/instaloader/git/trees{/sha}", | ||
"statuses_url": "https://api.github.com/repos/instaloader/instaloader/statuses/{sha}", | ||
"languages_url": "https://api.github.com/repos/instaloader/instaloader/languages", | ||
"stargazers_url": "https://api.github.com/repos/instaloader/instaloader/stargazers", | ||
"contributors_url": "https://api.github.com/repos/instaloader/instaloader/contributors", | ||
"subscribers_url": "https://api.github.com/repos/instaloader/instaloader/subscribers", | ||
"subscription_url": "https://api.github.com/repos/instaloader/instaloader/subscription", | ||
"commits_url": "https://api.github.com/repos/instaloader/instaloader/commits{/sha}", | ||
"git_commits_url": "https://api.github.com/repos/instaloader/instaloader/git/commits{/sha}", | ||
"comments_url": "https://api.github.com/repos/instaloader/instaloader/comments{/number}", | ||
"issue_comment_url": "https://api.github.com/repos/instaloader/instaloader/issues/comments{/number}", | ||
"contents_url": "https://api.github.com/repos/instaloader/instaloader/contents/{+path}", | ||
"compare_url": "https://api.github.com/repos/instaloader/instaloader/compare/{base}...{head}", | ||
"merges_url": "https://api.github.com/repos/instaloader/instaloader/merges", | ||
"archive_url": "https://api.github.com/repos/instaloader/instaloader/{archive_format}{/ref}", | ||
"downloads_url": "https://api.github.com/repos/instaloader/instaloader/downloads", | ||
"issues_url": "https://api.github.com/repos/instaloader/instaloader/issues{/number}", | ||
"pulls_url": "https://api.github.com/repos/instaloader/instaloader/pulls{/number}", | ||
"milestones_url": "https://api.github.com/repos/instaloader/instaloader/milestones{/number}", | ||
"notifications_url": "https://api.github.com/repos/instaloader/instaloader/notifications{?since,all,participating}", | ||
"labels_url": "https://api.github.com/repos/instaloader/instaloader/labels{/name}", | ||
"releases_url": "https://api.github.com/repos/instaloader/instaloader/releases{/id}", | ||
"deployments_url": "https://api.github.com/repos/instaloader/instaloader/deployments", | ||
"created_at": "2016-06-15T10:40:37Z", | ||
"updated_at": "2020-05-13T13:33:20Z", | ||
"pushed_at": "2020-05-11T18:27:23Z", | ||
"git_url": "git://github.com/instaloader/instaloader.git", | ||
"ssh_url": "git@github.com:instaloader/instaloader.git", | ||
"clone_url": "https://github.com/instaloader/instaloader.git", | ||
"svn_url": "https://github.com/instaloader/instaloader", | ||
"homepage": "https://instaloader.github.io/", | ||
"size": 1477, | ||
"stargazers_count": 1561, | ||
"watchers_count": 1561, | ||
"language": "Python", | ||
"has_issues": true, | ||
"has_projects": false, | ||
"has_downloads": true, | ||
"has_wiki": false, | ||
"has_pages": false, | ||
"forks_count": 281, | ||
"mirror_url": null, | ||
"archived": false, | ||
"disabled": false, | ||
"open_issues_count": 54, | ||
"license": { | ||
"key": "mit", | ||
"name": "MIT License", | ||
"spdx_id": "MIT", | ||
"url": "https://api.github.com/licenses/mit", | ||
"node_id": "MDc6TGljZW5zZTEz" | ||
}, | ||
"forks": 281, | ||
"open_issues": 54, | ||
"watchers": 1561, | ||
"default_branch": "master", | ||
"temp_clone_token": null, | ||
"organization": { | ||
"login": "instaloader", | ||
"id": 37333353, | ||
"node_id": "MDEyOk9yZ2FuaXphdGlvbjM3MzMzMzUz", | ||
"avatar_url": "https://avatars0.githubusercontent.com/u/37333353?v=4", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/instaloader", | ||
"html_url": "https://github.com/instaloader", | ||
"followers_url": "https://api.github.com/users/instaloader/followers", | ||
"following_url": "https://api.github.com/users/instaloader/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/instaloader/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/instaloader/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/instaloader/subscriptions", | ||
"organizations_url": "https://api.github.com/users/instaloader/orgs", | ||
"repos_url": "https://api.github.com/users/instaloader/repos", | ||
"events_url": "https://api.github.com/users/instaloader/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/instaloader/received_events", | ||
"type": "Organization", | ||
"site_admin": false | ||
}, | ||
"network_count": 281, | ||
"subscribers_count": 79 | ||
} |