Skip to content

Commit

Permalink
Merge pull request #156 from valiot/EBKH/Add-team-to-repo
Browse files Browse the repository at this point in the history
EBKH/Add a repo to a team
  • Loading branch information
edgurgel authored Oct 7, 2018
2 parents 93b4dfc + 1590860 commit 82ea38f
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/tentacat/teams/repositories.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,19 @@ defmodule Tentacat.Teams.Repositories do
def list(client \\ %Client{}, team_id) do
get("teams/#{team_id}/repos", client)
end

@doc """
Add a team to a repository
## Example
Tentacat.Teams.Repositories.add 210840, org, repo
Tentacat.Teams.Repositories.add client, 210840, org, repo, %{permission: "push"}
More info at: https://developer.github.com/v3/teams/#add-or-update-team-repository
"""
@spec add(Client.t(), integer, binary, binary) :: Tentacat.response()
def add(client \\ %Client{}, team_id, owner, repo, body \\ %{}) do
put("teams/#{team_id}/repos/#{owner}/#{repo}", client, body)
end
end
43 changes: 43 additions & 0 deletions test/fixture/vcr_cassettes/teams/repositories#add.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[
{
"request": {
"body": "{}",
"headers": {
"User-agent": "tentacat",
"Authorization": "token yourtokencomeshere"
},
"method": "put",
"options": [],
"request_body": "",
"url": "https://api.github.com/teams/1500000/repos/valiot/tentacat"
},
"response": {
"binary": false,
"body": "",
"headers": {
"Server": "GitHub.com",
"Date": "Thu, 04 Oct 2018 21:40:39 GMT",
"Content-Type": "application/octet-stream",
"Status": "204 No Content",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4997",
"X-RateLimit-Reset": "1538692794",
"X-OAuth-Scopes": "repo",
"X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org",
"X-GitHub-Media-Type": "github.v3; format=json",
"Access-Control-Expose-Headers": "ETag, Link, Retry-After, 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-Frame-Options": "deny",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "1; mode=block",
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"X-Runtime-rack": "0.163869",
"X-GitHub-Request-Id": "E550:197E:A7ACD6C:15C567C3:5BB688D6"
},
"status_code": 204,
"type": "ok"
}
}
]
6 changes: 6 additions & 0 deletions test/teams/repositories_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ defmodule Tentacat.Teams.RepositoriesTest do
assert elem(list(@client, 1_500_000), 1) == []
end
end

test "add/4" do
use_cassette "teams/repositories#add" do
assert elem(add(@client, 1_500_000, "valiot", "tentacat"), 1) == nil
end
end
end

0 comments on commit 82ea38f

Please sign in to comment.