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

PR: add pagination to Tentacat.Organizations.Members.list/3 for #210 #220

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/tentacat/organizations/members.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ defmodule Tentacat.Organizations.Members do

Tentacat.Organizations.Members.list "github"
Tentacat.Organizations.Members.list client, "github"
Tentacat.Organizations.Members.list client, "github", %{page: 2}

More info at: http://developer.github.com/v3/orgs/members/#members-list
"""
@spec list(Client.t(), binary) :: Tentacat.response()
def list(client \\ %Client{}, organization) do
get("orgs/#{organization}/members", client)
@spec list(Client.t(), binary, Keyword.t()) :: Tentacat.response()
def list(client \\ %Client{}, organization, options \\ []) do
get("orgs/#{organization}/members", client, options)
end

@doc """
Expand Down
13 changes: 11 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@ defmodule Tentacat.Mixfile do
elixir: "~> 1.16",
name: "Tentacat",
test_coverage: [tool: ExCoveralls],
preferred_cli_env: [coveralls: :test, "coveralls.detail": :test, "coveralls.post": :test],
preferred_cli_env: [
coveralls: :test,
"coveralls.detail": :test,
"coveralls.post": :test,
c: :test
],
package: package(),
deps: deps(),
docs: docs()
docs: docs(),
aliases: [
t: ["test"],
c: ["coveralls.html"]
]
]
end

Expand Down
46 changes: 46 additions & 0 deletions test/fixture/vcr_cassettes/members#list_with_params.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"request": {
"body": "\"\"",
"headers": {
"User-agent": "tentacat",
"Authorization": "token yourtokencomeshere"
},
"method": "get",
"options": [],
"request_body": "",
"url": "https://api.github.com/orgs/dwyl/members?page=2"
},
"response": {
"body": "[{\"login\":\"josephwilk\",\"id\":9792,\"avatar_url\":\"https://avatars.githubusercontent.com/u/9792?v=3\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/josephwilk\",\"html_url\":\"https://github.com/josephwilk\",\"followers_url\":\"https://api.github.com/users/josephwilk/followers\",\"following_url\":\"https://api.github.com/users/josephwilk/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/josephwilk/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/josephwilk/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/josephwilk/subscriptions\",\"organizations_url\":\"https://api.github.com/users/josephwilk/orgs\",\"repos_url\":\"https://api.github.com/users/josephwilk/repos\",\"events_url\":\"https://api.github.com/users/josephwilk/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/josephwilk/received_events\",\"type\":\"User\",\"site_admin\":false}]",
"headers": {
"Server": "GitHub.com",
"Date": "Thu, 10 Dec 2015 22:17:43 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "1739",
"Status": "200 OK",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4993",
"X-RateLimit-Reset": "1449785982",
"Cache-Control": "private, max-age=60, s-maxage=60",
"ETag": "\"7a18009ec36ef8d2939950529c9a7fa5\"",
"X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user",
"X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org",
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP",
"X-GitHub-Media-Type": "github.v3; format=json",
"X-XSS-Protection": "1; mode=block",
"X-Frame-Options": "deny",
"Content-Security-Policy": "default-src 'none'",
"Access-Control-Allow-Credentials": "true",
"Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval",
"Access-Control-Allow-Origin": "*",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Content-Type-Options": "nosniff",
"X-Served-By": "4c8b2d4732c413f4b9aefe394bd65569",
"X-GitHub-Request-Id": "5F5BD13E:A39A:484FE95:5669FA06"
},
"status_code": 200,
"type": "ok"
}
}
]
7 changes: 7 additions & 0 deletions test/organizations/members_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ defmodule Tentacat.Organizations.MembersTest do
end
end

test "list/3 second page of people" do
use_cassette "members#list_with_params" do
{_, [%{"login" => login}], _} = list(@client, "dwyl", %{page: 2})
assert login == "josephwilk"
end
end

test "member?/3" do
use_cassette "members#member_" do
{status_code, _, _} = member?(@client, "elixir-conspiracy", "josephwilk")
Expand Down
Loading