Skip to content

Commit

Permalink
Merge 35916d6 into 248ae17
Browse files Browse the repository at this point in the history
  • Loading branch information
duksis committed Dec 20, 2015
2 parents 248ae17 + 35916d6 commit 3777d18
Show file tree
Hide file tree
Showing 112 changed files with 4,668 additions and 26 deletions.
9 changes: 9 additions & 0 deletions lib/tentacat/hooks.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ defmodule Tentacat.Hooks do
end

@doc """
hook_body = %{
"name" => "web",
"active" => true,
"events" => [ "push", "pull_request" ],
"config" => {
"url" => "http://example.com/webhook",
"content_type" => "json"
}
}
## Example
Expand Down
20 changes: 7 additions & 13 deletions lib/tentacat/issues/comments.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule Tentacat.Issues.Comments do
List comments on an issue. Issue Comments are ordered by ascending ID.
## Example
Tentacat.Issues.Comments.list "elixir-lang", "elixir", 3970
More info at: https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
Expand All @@ -20,7 +20,7 @@ defmodule Tentacat.Issues.Comments do
List all comments on issues for a repository. By default, Issue Comments are ordered by ascending ID.
## Example
Tentacat.Issues.Comments.list_all "elixir-lang", "elixir"
More info at: https://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
Expand All @@ -34,7 +34,7 @@ defmodule Tentacat.Issues.Comments do
Get a single comment on an issue by its id.
## Example
Tentacat.Issues.Comments.find "elixir-lang", "elixir", 882148
https://developer.github.com/v3/issues/comments/#get-a-single-comment
Expand All @@ -50,10 +50,7 @@ defmodule Tentacat.Issues.Comments do
Comment body example:
```
%{
"body" => "Nice change",
"commit_id" => "6dcb09b5b57875f334f61aebed695e2e4193db5e",
"path" => "file1.txt",
"position" => 4
"body" => "Nice change"
}
```
Expand All @@ -67,17 +64,14 @@ defmodule Tentacat.Issues.Comments do
def create(owner, repo, issue_id, body, client \\ %Client{}) do
post "repos/#{owner}/#{repo}/issues/#{issue_id}/comments", client, body
end

@doc """
Update a comment on an issue by id.
Comment body example:
```
%{
"body" => "Nice change",
"commit_id" => "6dcb09b5b57875f334f61aebed695e2e4193db5e",
"path" => "file1.txt",
"position" => 4
"body" => "Nice change"
}
```
Expand All @@ -91,7 +85,7 @@ defmodule Tentacat.Issues.Comments do
def update(owner, repo, issue_id, comment_id, body, client \\ %Client{}) do
patch "repos/#{owner}/#{repo}/issues/#{issue_id}/comments/#{comment_id}", client, body
end

@doc """
Delete a comment on an issue by id.
Expand Down
File renamed without changes.
61 changes: 61 additions & 0 deletions test/commits/comments_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
defmodule Tentacat.Commits.CommentsTest do
use ExUnit.Case, async: false
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
import Tentacat.Commits.Comments

doctest Tentacat.Commits.Comments

@client Tentacat.Client.new(%{access_token: "8e663c8614ced27c09b963f806ac46776a29db50"})

setup_all do
HTTPoison.start
end

test "list_all/3" do
use_cassette "commits/comments#list_all" do
assert list_all("tentatest", "tentacat", @client) == []
end
end

test "list/4" do
use_cassette "commits/comments#list" do
assert list("soudqwiggle", "elixir-conspiracy", "b426f957a26cd4d632da3b174372c973ab083523", @client) == []
end
end

test "find/4" do
use_cassette "commits/comments#find" do
%{"body" => body} = find("soudqwiggle", "elixir-conspiracy", 15079374, @client)
assert body == ":sheep: :lv:"
end
end

test "create/5" do
body = %{
"body" => ":sheep: :it:",
"path" => "README.md",
"position" => 1
}
use_cassette "commits/comments#create" do
{status_code, _} = create("soudqwiggle", "elixir-conspiracy", "b426f957a26cd4d632da3b174372c973ab083523", body, @client)
assert status_code == 201
end
end

test "update/5" do
body = %{
"body" => ":sheep: :lv:"
}
use_cassette "commits/comments#update" do
%{"id" => commit_id} = update("soudqwiggle", "elixir-conspiracy", 15079374, body, @client)
assert commit_id == 15079374
end
end

test "delete/4" do
use_cassette "commits/comments#delete" do
{status_code, _} = delete("soudqwiggle", "elixir-conspiracy", 15079374, @client)
assert status_code == 204
end
end
end
77 changes: 77 additions & 0 deletions test/contents_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
defmodule Tentacat.ContentsTest do
use ExUnit.Case, async: false
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
import Tentacat.Contents

doctest Tentacat.Contents

@client Tentacat.Client.new(%{access_token: "yourtokencomeshere"})

setup_all do
HTTPoison.start
end

test "find/4" do
use_cassette "contents#find" do
[%{"sha" => sha}] = find("elixir-lang", "elixir", "lib", @client)
assert sha == "c928b5d4c7fa3c0c665cb2d2f591def3bdf29c38"
end
end

test "find_in/5" do
use_cassette "contents#find_in" do
[%{"sha" => sha}] = find_in("elixir-lang", "elixir", "lib", "master", @client)
assert sha == "c928b5d4c7fa3c0c665cb2d2f591def3bdf29c38"
end
end

test "create/5" do
body = %{
"message" => "Initial commit",
"committer" => %{
"name" => "Soud Qwiggle",
"email"=> "soud@qwiggle.com"
},
"content" => Base.encode64("# Yoop!"),
"branch"=> "master"
}
use_cassette "contents#create" do
{status_code, _} = create("soudqwiggle", "elixir-conspiracy", "README.md", body, @client)
assert status_code == 201
end
end

test "update/5" do
body = %{
"message" => "commit after the initial commit",
"committer" => %{
"name" => "Soud Qwiggle",
"email"=> "soud@qwiggle.com"
},
"content" => Base.encode64("## Woop!"),
"sha" => "f6147c986f215f640f86f4e337748e3a311bf281",
"branch"=> "master"
}
use_cassette "contents#update" do
%{"commit" => %{"sha" => sha}} = update("soudqwiggle", "elixir-conspiracy", "README.md", body, @client)
assert sha == "bf7c4ab53fe7503b82b9654d5979ebe8c24ea009"
end
end

test "remove/5" do
body = %{
"message" => "remove readme",
"committer" => %{
"name" => "Soud Qwiggle",
"email"=> "soud@qwiggle.com"
},
"sha" => "c2fb5f1db1767d8f1435952f640ac8e385612482",
"branch"=> "master"
}
use_cassette "contents#remove" do
%{"commit"=>%{"sha"=>sha}} = remove("soudqwiggle", "elixir-conspiracy", "README.md", body, @client)
assert sha == "2ff6f7942773c268dc9ab0e11e9dffad402c1860"
end
end

end
47 changes: 47 additions & 0 deletions test/fixture/vcr_cassettes/commits/comments#create.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[
{
"request": {
"body": "{\"body\":\":sheep: :it:\",\"path\":\"README.md\",\"position\":1}",
"headers": {
"User-agent": "tentacat",
"Authorization": "token yourtokencomeshere"
},
"method": "post",
"options": [],
"request_body": "",
"url": "https://api.github.com/repos/soudqwiggle/elixir-conspiracy/commits/b426f957a26cd4d632da3b174372c973ab083523/comments"
},
"response": {
"body": "{\"url\":\"https://api.github.com/repos/soudqwiggle/elixir-conspiracy/comments/15084673\",\"html_url\":\"https://github.com/soudqwiggle/elixir-conspiracy/commit/b426f957a26cd4d632da3b174372c973ab083523#commitcomment-15084673\",\"id\":15084673,\"user\":{\"login\":\"soudqwiggle\",\"id\":16187637,\"avatar_url\":\"https://avatars.githubusercontent.com/u/16187637?v=3\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/soudqwiggle\",\"html_url\":\"https://github.com/soudqwiggle\",\"followers_url\":\"https://api.github.com/users/soudqwiggle/followers\",\"following_url\":\"https://api.github.com/users/soudqwiggle/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/soudqwiggle/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/soudqwiggle/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/soudqwiggle/subscriptions\",\"organizations_url\":\"https://api.github.com/users/soudqwiggle/orgs\",\"repos_url\":\"https://api.github.com/users/soudqwiggle/repos\",\"events_url\":\"https://api.github.com/users/soudqwiggle/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/soudqwiggle/received_events\",\"type\":\"User\",\"site_admin\":false},\"position\":1,\"line\":null,\"path\":\"README.md\",\"commit_id\":\"b426f957a26cd4d632da3b174372c973ab083523\",\"created_at\":\"2015-12-20T09:22:00Z\",\"updated_at\":\"2015-12-20T09:22:00Z\",\"body\":\":sheep: :it:\"}",
"headers": {
"Server": "GitHub.com",
"Date": "Sun, 20 Dec 2015 09:22:00 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "1344",
"Status": "201 Created",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4998",
"X-RateLimit-Reset": "1450606885",
"Cache-Control": "private, max-age=60, s-maxage=60",
"ETag": "\"f2002c5e6017d69d476d8e21e31f3bc0\"",
"X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user",
"X-Accepted-OAuth-Scopes": "",
"Location": "https://api.github.com/repos/soudqwiggle/elixir-conspiracy/comments/15084673",
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP",
"X-GitHub-Media-Type": "github.v3; format=json",
"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": "*",
"Content-Security-Policy": "default-src 'none'",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "deny",
"X-XSS-Protection": "1; mode=block",
"X-Served-By": "b0ef53392caa42315c6206737946d931",
"X-GitHub-Request-Id": "3E552BA7:A39B:1462E87E:56767338"
},
"status_code": 201,
"type": "ok"
}
}
]
42 changes: 42 additions & 0 deletions test/fixture/vcr_cassettes/commits/comments#delete.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"request": {
"body": "\"\"",
"headers": {
"User-agent": "tentacat",
"Authorization": "token yourtokencomeshere"
},
"method": "delete",
"options": [],
"request_body": "",
"url": "https://api.github.com/repos/soudqwiggle/elixir-conspiracy/comments/15079374"
},
"response": {
"body": "#Reference<0.0.4.8>",
"headers": {
"Server": "GitHub.com",
"Date": "Sat, 19 Dec 2015 06:55:59 GMT",
"Status": "204 No Content",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4988",
"X-RateLimit-Reset": "1450510991",
"X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user",
"X-Accepted-OAuth-Scopes": "",
"X-GitHub-Media-Type": "github.v3; format=json",
"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": "*",
"Content-Security-Policy": "default-src 'none'",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "deny",
"X-XSS-Protection": "1; mode=block",
"Vary": "Accept-Encoding",
"X-Served-By": "474556b853193c38f1b14328ce2d1b7d",
"X-GitHub-Request-Id": "3E552BA7:14B62:11E05A37:5674FF7E"
},
"status_code": 204,
"type": "ok"
}
}
]
47 changes: 47 additions & 0 deletions test/fixture/vcr_cassettes/commits/comments#find.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[
{
"request": {
"body": "\"\"",
"headers": {
"User-agent": "tentacat",
"Authorization": "token yourtokencomeshere"
},
"method": "get",
"options": [],
"request_body": "",
"url": "https://api.github.com/repos/soudqwiggle/elixir-conspiracy/comments/15079374"
},
"response": {
"body": "{\"url\":\"https://api.github.com/repos/soudqwiggle/elixir-conspiracy/comments/15079374\",\"html_url\":\"https://github.com/soudqwiggle/elixir-conspiracy/commit/b426f957a26cd4d632da3b174372c973ab083523#commitcomment-15079374\",\"id\":15079374,\"user\":{\"login\":\"soudqwiggle\",\"id\":16187637,\"avatar_url\":\"https://avatars.githubusercontent.com/u/16187637?v=3\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/soudqwiggle\",\"html_url\":\"https://github.com/soudqwiggle\",\"followers_url\":\"https://api.github.com/users/soudqwiggle/followers\",\"following_url\":\"https://api.github.com/users/soudqwiggle/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/soudqwiggle/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/soudqwiggle/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/soudqwiggle/subscriptions\",\"organizations_url\":\"https://api.github.com/users/soudqwiggle/orgs\",\"repos_url\":\"https://api.github.com/users/soudqwiggle/repos\",\"events_url\":\"https://api.github.com/users/soudqwiggle/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/soudqwiggle/received_events\",\"type\":\"User\",\"site_admin\":false},\"position\":1,\"line\":null,\"path\":\"README.md\",\"commit_id\":\"b426f957a26cd4d632da3b174372c973ab083523\",\"created_at\":\"2015-12-19T06:49:35Z\",\"updated_at\":\"2015-12-19T06:52:58Z\",\"body\":\":sheep: :lv:\"}",
"headers": {
"Server": "GitHub.com",
"Date": "Sat, 19 Dec 2015 06:55:01 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "1344",
"Status": "200 OK",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4989",
"X-RateLimit-Reset": "1450510991",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Last-Modified": "Sat, 19 Dec 2015 06:52:58 GMT",
"ETag": "\"e5116d2d3c79b23cf73426bda2c49d24\"",
"X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user",
"X-Accepted-OAuth-Scopes": "",
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP",
"X-GitHub-Media-Type": "github.v3; format=json",
"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": "*",
"Content-Security-Policy": "default-src 'none'",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "deny",
"X-XSS-Protection": "1; mode=block",
"X-Served-By": "d0b3c2c33a23690498aa8e70a435a259",
"X-GitHub-Request-Id": "3E552BA7:A396:5205883:5674FF44"
},
"status_code": 200,
"type": "ok"
}
}
]
Loading

0 comments on commit 3777d18

Please sign in to comment.