forked from edgurgel/tentacat
-
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.
Add support for repositories/contributors
- Loading branch information
Antony Denyer
committed
Oct 10, 2017
1 parent
e0df824
commit 9b87cb1
Showing
4 changed files
with
51 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
defmodule Tentacat.Repositories.Contributors do | ||
import Tentacat | ||
alias Tentacat.Client | ||
|
||
@doc """ | ||
List contributors for a specific repository | ||
## Example | ||
Tentacat.Repositories.contributors.list "elixir-lang", "elixir" | ||
Tentacat.Repositories.contributors.list "elixir-lang", "elixir", client | ||
More info at: https://developer.github.com/v3/repos/#list-contributors | ||
""" | ||
@spec list(binary, binary, Client.t) :: Tentacat.response | ||
def list(owner, repo, client \\ %Client{}) do | ||
get "repos/#{owner}/#{repo}/contributors", client | ||
end | ||
|
||
end |
12 changes: 12 additions & 0 deletions
12
test/fixture/vcr_cassettes/repositories/contributors#list.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,12 @@ | ||
[ | ||
{ | ||
"request": { | ||
"url": "https://api.github.com/repos/antonydenyer/tentatest/contributors" | ||
}, | ||
"response": { | ||
"body": "[{\"login\":\"octocat\",\"id\":1,\"avatar_url\":\"https://github.com/images/error/octocat_happy.gif\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/octocat\",\"html_url\":\"https://github.com/octocat\",\"followers_url\":\"https://api.github.com/users/octocat/followers\",\"following_url\":\"https://api.github.com/users/octocat/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/octocat/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/octocat/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/octocat/subscriptions\",\"organizations_url\":\"https://api.github.com/users/octocat/orgs\",\"repos_url\":\"https://api.github.com/users/octocat/repos\",\"events_url\":\"https://api.github.com/users/octocat/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/octocat/received_events\",\"type\":\"User\",\"site_admin\":false,\"contributions\":32}]", | ||
"status_code": 200, | ||
"type": "ok" | ||
} | ||
} | ||
] |
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,19 @@ | ||
defmodule Tentacat.Repositories.ContributorsTest do | ||
use ExUnit.Case, async: false | ||
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney | ||
import Tentacat.Repositories.Contributors | ||
|
||
doctest Tentacat.Repositories.Contributors | ||
|
||
@client Tentacat.Client.new(%{access_token: "yourtokencomeshere"}) | ||
|
||
setup_all do | ||
HTTPoison.start | ||
end | ||
|
||
test "list/3" do | ||
use_cassette "repositories/contributors#list" do | ||
assert list("antonydenyer", "tentatest", @client) |> Enum.count() == 1 | ||
end | ||
end | ||
end |