From 8cda4edf0751ff333cbd144bac96a5df8c55c628 Mon Sep 17 00:00:00 2001 From: nelsonic Date: Sun, 15 Dec 2024 07:55:55 +0000 Subject: [PATCH 1/3] add pagination to Tentacat.Organizations.Members.list/3 fixes https://github.com/edgurgel/tentacat/issues/210 --- lib/tentacat/organizations/members.ex | 7 ++++--- mix.exs | 8 ++++++-- test/organizations/members_test.exs | 7 +++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/tentacat/organizations/members.ex b/lib/tentacat/organizations/members.ex index 1997848..97084f5 100644 --- a/lib/tentacat/organizations/members.ex +++ b/lib/tentacat/organizations/members.ex @@ -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 """ diff --git a/mix.exs b/mix.exs index e4ca5d0..7ab80b0 100644 --- a/mix.exs +++ b/mix.exs @@ -11,10 +11,14 @@ 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 diff --git a/test/organizations/members_test.exs b/test/organizations/members_test.exs index cc6ea5d..38d6bd0 100644 --- a/test/organizations/members_test.exs +++ b/test/organizations/members_test.exs @@ -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") From 42a8a1dbc2f92d0e28d756bd806e0ce2e89e9f24 Mon Sep 17 00:00:00 2001 From: nelsonic Date: Sun, 15 Dec 2024 07:59:09 +0000 Subject: [PATCH 2/3] create test/fixture/vcr_cassettes/members#list_with_params.json for #210 --- .../members#list_with_params.json | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/fixture/vcr_cassettes/members#list_with_params.json diff --git a/test/fixture/vcr_cassettes/members#list_with_params.json b/test/fixture/vcr_cassettes/members#list_with_params.json new file mode 100644 index 0000000..4168791 --- /dev/null +++ b/test/fixture/vcr_cassettes/members#list_with_params.json @@ -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" + } + } +] From b1659be487d73e57b300fff6875adcb25904a7c0 Mon Sep 17 00:00:00 2001 From: nelsonic Date: Thu, 19 Dec 2024 21:53:51 +0000 Subject: [PATCH 3/3] mix format https://github.com/edgurgel/tentacat/actions/runs/12337052631/job/34680054351#step:6:1 --- mix.exs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index 7ab80b0..8e5daa5 100644 --- a/mix.exs +++ b/mix.exs @@ -11,7 +11,12 @@ defmodule Tentacat.Mixfile do elixir: "~> 1.16", name: "Tentacat", test_coverage: [tool: ExCoveralls], - preferred_cli_env: [coveralls: :test, "coveralls.detail": :test, "coveralls.post": :test, c: :test], + preferred_cli_env: [ + coveralls: :test, + "coveralls.detail": :test, + "coveralls.post": :test, + c: :test + ], package: package(), deps: deps(), docs: docs(),