Skip to content

Commit 9bb08b6

Browse files
committed
Add acceptance testing
1 parent a86ed1b commit 9bb08b6

File tree

7 files changed

+32
-21
lines changed

7 files changed

+32
-21
lines changed

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ export CLOUDEX_SECRET=
66
export CLOUDFRONT_DOMAIN=
77
export GITHUB_APP_CLIENT_ID=
88
export GITHUB_APP_CLIENT_SECRET=
9+
export GITHUB_APP_ID=
910
export GITHUB_APP_PEM=
11+
export GITHUB_TEST_APP_CLIENT_ID=
12+
export GITHUB_TEST_APP_CLIENT_SECRET=
13+
export GITHUB_TEST_APP_ID=
14+
export GITHUB_TEST_APP_PEM=
1015
export INTERCOM_IDENTITY_SECRET_KEY=
1116
export POSTMARK_API_KEY=
1217
export S3_BUCKET=

circle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test:
1717
if [ ${CIRCLE_PR_USERNAME} ]; then
1818
MIX_ENV=test mix test;
1919
else
20-
MIX_ENV=test mix coveralls.circle;
20+
MIX_ENV=test mix coveralls.circle --include acceptance:true;
2121
fi
2222
post:
2323
- mix inch.report

config/dev.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use Mix.Config
77
# watchers to your application. For example, we use it
88
# with brunch.io to recompile .js and .css sources.
99
config :code_corps, CodeCorpsWeb.Endpoint,
10-
http: [port: 4000, ip: {0, 0, 0, 0, 0, 0, 0, 0}],
10+
http: [port: 4000],
1111
debug_errors: true,
1212
code_reloader: true,
1313
check_origin: false

config/test.exs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,18 @@ config :code_corps, :icon_color_generator, CodeCorps.RandomIconColor.TestGenerat
4141
# Set Corsica logging to output no console warning when rejecting a request
4242
config :code_corps, :corsica_log_level, [rejected: :debug]
4343

44-
# Set the GitHub module
45-
config :code_corps, github: CodeCorps.GitHubTesting
44+
# fall back to sample pem if none is available as an ENV variable
45+
pem = case System.get_env("GITHUB_TEST_APP_PEM") do
46+
nil -> "./test/fixtures/github/app.pem" |> File.read!
47+
encoded_pem -> encoded_pem |> Base.decode64!
48+
end
49+
50+
config :code_corps,
51+
github: CodeCorps.GitHub.SuccessAPI,
52+
github_app_id: System.get_env("GITHUB_TEST_APP_ID"),
53+
github_app_client_id: System.get_env("GITHUB_TEST_APP_CLIENT_ID"),
54+
github_app_client_secret: System.get_env("GITHUB_TEST_APP_CLIENT_SECRET"),
55+
github_app_pem: pem
4656

4757
config :sentry,
4858
environment_name: Mix.env || :test
@@ -57,13 +67,3 @@ config :code_corps,
5767

5868
config :code_corps, :cloudex, CloudexTest
5969
config :cloudex, api_key: "test_key", secret: "test_secret", cloud_name: "test_cloud_name"
60-
61-
# fall back to sample pem if none is available as an ENV variable
62-
pem = case System.get_env("GITHUB_APP_PEM") do
63-
nil -> "./test/fixtures/github/app.pem" |> File.read!
64-
encoded_pem -> encoded_pem |> Base.decode64!
65-
end
66-
67-
config :code_corps,
68-
github: CodeCorps.GitHub.SuccessAPI,
69-
github_app_pem: pem

mix.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ defmodule CodeCorps.Mixfile do
407407
"ecto.reset": ["ecto.drop", "ecto.setup"],
408408
"ecto.migrate": ["ecto.migrate", "ecto.dump"],
409409
"ecto.rollback": ["ecto.rollback", "ecto.dump"],
410-
"test": ["ecto.create --quiet", "ecto.migrate", "test"]]
410+
"test": ["ecto.create --quiet", "ecto.migrate", "test"],
411+
"test.acceptance": ["ecto.create --quiet", "ecto.migrate", "test --include acceptance:true"]]
411412
end
412413
end

test/lib/code_corps/github/api/repository_test.exs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ defmodule CodeCorps.GitHub.API.RepositoryTest do
33

44
use CodeCorps.DbAccessCase
55

6+
import CodeCorps.GitHub.TestHelpers
7+
68
alias CodeCorps.{
79
GitHub.API.Repository
810
}
@@ -33,15 +35,17 @@ defmodule CodeCorps.GitHub.API.RepositoryTest do
3335
assert Enum.count(issues) == 8
3436
end
3537

38+
@tag acceptance: true
3639
test "calls github API with the real API" do
37-
owner = "baxterthehacker"
38-
repo = "public-repo"
39-
github_app_installation = insert(:github_app_installation, github_account_login: owner)
40+
owner = "coderly"
41+
repo = "github-app-testing"
42+
github_app_installation = insert(:github_app_installation, github_account_login: owner, github_id: 63365)
4043
github_repo = insert(:github_repo, github_app_installation: github_app_installation, name: repo)
4144

42-
{:ok, issues} = Repository.issues(github_repo)
43-
44-
assert Enum.count(issues) == 8
45+
with_real_api do
46+
{:ok, issues} = Repository.issues(github_repo)
47+
assert Enum.count(issues) == 1
48+
end
4549
end
4650
end
4751
end

test/test_helper.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{:ok, _} = Application.ensure_all_started(:ex_machina)
44
{:ok, _} = Application.ensure_all_started(:bypass)
55

6+
ExUnit.configure exclude: [acceptance: true]
67
ExUnit.start
78

89
Ecto.Adapters.SQL.Sandbox.mode(CodeCorps.Repo, :manual)

0 commit comments

Comments
 (0)