Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHubからリポジトリの情報を取得できるようにした #18

Merged
merged 1 commit into from
Sep 28, 2018

Conversation

orekyuu
Copy link
Owner

@orekyuu orekyuu commented Sep 28, 2018

refs: #2
リポジトリを登録するときに自分のリポジトリ一覧が見れる必要がある。
GitHubからリポジトリの一覧を持ってこれるようにした。

/**
* @see <a href="https://developer.github.com/v3/repos/#response">github document</a>
*/
public class GithubRepository {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GithubRepositoryを取得するのはGithubRepositoryRepository?やばいな。と一瞬考えたがこれが一番わかり易いと思った。いい名前案絶賛募集中です


@Test
public void testFetchRepository() {
MockRestServiceServer server = MockRestServiceServer.createServer(restTemplate);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RestTemplateでAPIを叩くテストをするときはMockRestServiceServerを使うと叩いた先をMockすることができて便利。

public void testFetchRepository() {
MockRestServiceServer server = MockRestServiceServer.createServer(restTemplate);
//<editor-fold desc="test rest server">
server.expect(requestTo("https://api.github.com/user/repos")).andRespond(withSuccess("[\n" +
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requestToで叩かれるエンドポイントを指定して、andRespondで返したいレスポンスを渡す。仮にrequestToの値が間違っていればテストが落ちてくれる。

Copy link
Collaborator

@nokok nokok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@orekyuu orekyuu merged commit 8abd94f into master Sep 28, 2018
@orekyuu orekyuu deleted the fetch-github-repository branch September 28, 2018 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants