Skip to content

Commit

Permalink
Adds tests for #48 commits and repo tags
Browse files Browse the repository at this point in the history
  • Loading branch information
duksis committed Dec 31, 2015
1 parent 22634c6 commit 1bb5e1a
Show file tree
Hide file tree
Showing 6 changed files with 241 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/commits_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
defmodule Tentacat.CommitsTest do
use ExUnit.Case, async: false
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
import Tentacat.Commits

doctest Tentacat.Commits

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

setup_all do
HTTPoison.start
end

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

test "find/4" do
use_cassette "commits#find" do
%{"sha" => sha} = find("09fe12ca25d0440f", "soudqwiggle", "elixir-conspiracy", @client)
assert sha == "09fe12ca25d0440f143ab331e4684a8622d6e4e5"
end
end

test "compare/5" do
use_cassette "commits#compare" do
%{"total_commits" => total_commits} = compare("master", "09fe12ca25d0440f", "soudqwiggle", "elixir-conspiracy", @client)
assert total_commits == 0
end
end
end
47 changes: 47 additions & 0 deletions test/fixture/vcr_cassettes/commits#compare.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/compare/master...09fe12ca25d0440f"
},
"response": {
"body": "{\"url\":\"https://api.github.com/repos/soudqwiggle/elixir-conspiracy/compare/master...09fe12ca25d0440f\",\"html_url\":\"https://github.com/soudqwiggle/elixir-conspiracy/compare/master...09fe12ca25d0440f\",\"permalink_url\":\"https://github.com/soudqwiggle/elixir-conspiracy/compare/soudqwiggle:bf7c4ab...soudqwiggle:09fe12c\",\"diff_url\":\"https://github.com/soudqwiggle/elixir-conspiracy/compare/master...09fe12ca25d0440f.diff\",\"patch_url\":\"https://github.com/soudqwiggle/elixir-conspiracy/compare/master...09fe12ca25d0440f.patch\",\"base_commit\":{\"sha\":\"bf7c4ab53fe7503b82b9654d5979ebe8c24ea009\",\"commit\":{\"author\":{\"name\":\"Soud Qwiggle\",\"email\":\"[email protected]\",\"date\":\"2015-12-10T21:51:01Z\"},\"committer\":{\"name\":\"Soud Qwiggle\",\"email\":\"[email protected]\",\"date\":\"2015-12-10T21:51:01Z\"},\"message\":\"commit after the initial commit\",\"tree\":{\"sha\":\"13eda2537eb875280fa0ce32779a6e9cf0d1e2ad\",\"url\":\"https://api.github.com/repos/soudqwiggle/elixir-conspiracy/git/trees/13eda2537eb875280fa0ce32779a6e9cf0d1e2ad\"},\"url\":\"https://api.github.com/repos/soudqwiggle/elixir-conspiracy/git/commits/bf7c4ab53fe7503b82b9654d5979ebe8c24ea009\",\"comment_count\":0},\"url\":\"https://api.github.com/repos/soudqwiggle/elixir-conspiracy/commits/bf7c4ab53fe7503b82b9654d5979ebe8c24ea009\",\"html_url\":\"https://github.com/soudqwiggle/elixir-conspiracy/commit/bf7c4ab53fe7503b82b9654d5979ebe8c24ea009\",\"comments_url\":\"https://api.github.com/repos/soudqwiggle/elixir-conspiracy/commits/bf7c4ab53fe7503b82b9654d5979ebe8c24ea009/comments\",\"author\":null,\"committer\":null,\"parents\":[{\"sha\":\"09fe12ca25d0440f143ab331e4684a8622d6e4e5\",\"url\":\"https://api.github.com/repos/soudqwiggle/elixir-conspiracy/commits/09fe12ca25d0440f143ab331e4684a8622d6e4e5\",\"html_url\":\"https://github.com/soudqwiggle/elixir-conspiracy/commit/09fe12ca25d0440f143ab331e4684a8622d6e4e5\"}]},\"merge_base_commit\":{\"sha\":\"09fe12ca25d0440f143ab331e4684a8622d6e4e5\",\"commit\":{\"author\":{\"name\":\"Soud Qwiggle\",\"email\":\"[email protected]\",\"date\":\"2015-12-10T21:41:38Z\"},\"committer\":{\"name\":\"Soud Qwiggle\",\"email\":\"[email protected]\",\"date\":\"2015-12-10T21:41:38Z\"},\"message\":\"Initial commit\",\"tree\":{\"sha\":\"37b3b2c39cc38d6dcbdb9c27a5e0379c0b11005e\",\"url\":\"https://api.github.com/repos/soudqwiggle/elixir-conspiracy/git/trees/37b3b2c39cc38d6dcbdb9c27a5e0379c0b11005e\"},\"url\":\"https://api.github.com/repos/soudqwiggle/elixir-conspiracy/git/commits/09fe12ca25d0440f143ab331e4684a8622d6e4e5\",\"comment_count\":0},\"url\":\"https://api.github.com/repos/soudqwiggle/elixir-conspiracy/commits/09fe12ca25d0440f143ab331e4684a8622d6e4e5\",\"html_url\":\"https://github.com/soudqwiggle/elixir-conspiracy/commit/09fe12ca25d0440f143ab331e4684a8622d6e4e5\",\"comments_url\":\"https://api.github.com/repos/soudqwiggle/elixir-conspiracy/commits/09fe12ca25d0440f143ab331e4684a8622d6e4e5/comments\",\"author\":null,\"committer\":null,\"parents\":[]},\"status\":\"behind\",\"ahead_by\":0,\"behind_by\":1,\"total_commits\":0,\"commits\":[],\"files\":[]}",
"headers": {
"Server": "GitHub.com",
"Date": "Thu, 31 Dec 2015 14:34:34 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "2913",
"Status": "200 OK",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4998",
"X-RateLimit-Reset": "1451576074",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Last-Modified": "Thu, 10 Dec 2015 21:51:01 GMT",
"ETag": "\"fd80f0022aadd006f488bcae22c1031c\"",
"X-OAuth-Scopes": "gist, 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": "2811da37fbdda4367181b328b22b2499",
"X-GitHub-Request-Id": "55FE9E69:134F3:1EDEB922:56853CFA"
},
"status_code": 200,
"type": "ok"
}
}
]
47 changes: 47 additions & 0 deletions test/fixture/vcr_cassettes/commits#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/commits/09fe12ca25d0440f"
},
"response": {
"body": "{\"sha\":\"09fe12ca25d0440f143ab331e4684a8622d6e4e5\",\"commit\":{\"author\":{\"name\":\"Soud Qwiggle\",\"email\":\"[email protected]\",\"date\":\"2015-12-10T21:41:38Z\"},\"committer\":{\"name\":\"Soud Qwiggle\",\"email\":\"[email protected]\",\"date\":\"2015-12-10T21:41:38Z\"},\"message\":\"Initial commit\",\"tree\":{\"sha\":\"37b3b2c39cc38d6dcbdb9c27a5e0379c0b11005e\",\"url\":\"https://api.github.com/repos/soudqwiggle/elixir-conspiracy/git/trees/37b3b2c39cc38d6dcbdb9c27a5e0379c0b11005e\"},\"url\":\"https://api.github.com/repos/soudqwiggle/elixir-conspiracy/git/commits/09fe12ca25d0440f143ab331e4684a8622d6e4e5\",\"comment_count\":0},\"url\":\"https://api.github.com/repos/soudqwiggle/elixir-conspiracy/commits/09fe12ca25d0440f143ab331e4684a8622d6e4e5\",\"html_url\":\"https://github.com/soudqwiggle/elixir-conspiracy/commit/09fe12ca25d0440f143ab331e4684a8622d6e4e5\",\"comments_url\":\"https://api.github.com/repos/soudqwiggle/elixir-conspiracy/commits/09fe12ca25d0440f143ab331e4684a8622d6e4e5/comments\",\"author\":null,\"committer\":null,\"parents\":[],\"stats\":{\"total\":1,\"additions\":1,\"deletions\":0},\"files\":[{\"sha\":\"f6147c986f215f640f86f4e337748e3a311bf281\",\"filename\":\"README.md\",\"status\":\"added\",\"additions\":1,\"deletions\":0,\"changes\":1,\"blob_url\":\"https://github.com/soudqwiggle/elixir-conspiracy/blob/09fe12ca25d0440f143ab331e4684a8622d6e4e5/README.md\",\"raw_url\":\"https://github.com/soudqwiggle/elixir-conspiracy/raw/09fe12ca25d0440f143ab331e4684a8622d6e4e5/README.md\",\"contents_url\":\"https://api.github.com/repos/soudqwiggle/elixir-conspiracy/contents/README.md?ref=09fe12ca25d0440f143ab331e4684a8622d6e4e5\",\"patch\":\"@@ -0,0 +1 @@\\n+# Yoop!\\n\\\\ No newline at end of file\"}]}",
"headers": {
"Server": "GitHub.com",
"Date": "Thu, 31 Dec 2015 14:38:23 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "1616",
"Status": "200 OK",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4995",
"X-RateLimit-Reset": "1451576074",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Last-Modified": "Thu, 10 Dec 2015 21:41:38 GMT",
"ETag": "\"7ba656b6afd80de93b42f0c89d27a3a2\"",
"X-OAuth-Scopes": "gist, 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": "7f48e2f7761567e923121f17538d7a6d",
"X-GitHub-Request-Id": "55FE9E69:134F2:1864D97B:56853DDF"
},
"status_code": 200,
"type": "ok"
}
}
]
47 changes: 47 additions & 0 deletions test/fixture/vcr_cassettes/commits#list.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/commits"
},
"response": {
"body": "[]",
"headers": {
"Server": "GitHub.com",
"Date": "Thu, 31 Dec 2015 14:34:34 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "2274",
"Status": "200 OK",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4999",
"X-RateLimit-Reset": "1451576074",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Last-Modified": "Thu, 10 Dec 2015 21:51:01 GMT",
"ETag": "\"dd2aa8d5b87145391c7c55010b78bd51\"",
"X-OAuth-Scopes": "gist, 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": "3e3b9690823fb031da84658eb58aa83b",
"X-GitHub-Request-Id": "55FE9E69:134F3:1EDEB8A6:56853CF9"
},
"status_code": 200,
"type": "ok"
}
}
]
47 changes: 47 additions & 0 deletions test/fixture/vcr_cassettes/repositories/tags#list.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/tags"
},
"response": {
"body": "[]",
"headers": {
"Server": "GitHub.com",
"Date": "Thu, 31 Dec 2015 14:53:38 GMT",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "1105",
"Status": "200 OK",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4994",
"X-RateLimit-Reset": "1451576074",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Last-Modified": "Mon, 07 Dec 2015 21:36:13 GMT",
"ETag": "\"ffa7650ae6c624f166f89b351630d1af\"",
"X-OAuth-Scopes": "gist, 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": "5aeb3f30c9e3ef6ef7bcbcddfd9a68f7",
"X-GitHub-Request-Id": "55FE9E69:14B5D:103F1DF2:56854171"
},
"status_code": 200,
"type": "ok"
}
}
]
20 changes: 20 additions & 0 deletions test/repositories/tags_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
defmodule Tentacat.Repositories.TagsTest do
use ExUnit.Case, async: false
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
import Tentacat.Repositories.Tags

doctest Tentacat.Repositories.Tags

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

setup_all do
HTTPoison.start
end

test "list/3" do
use_cassette "repositories/tags#list" do
assert list("soudqwiggle", "elixir-conspiracy", @client) == []
end
end
end

0 comments on commit 1bb5e1a

Please sign in to comment.