Skip to content

Commit

Permalink
Test for api error during sync
Browse files Browse the repository at this point in the history
add tests for syncing existing repositories

remove erronous test
  • Loading branch information
zacck committed Feb 27, 2018
1 parent 0ccebdb commit e960094
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/lib/code_corps/github/sync/sync_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ defmodule CodeCorps.GitHub.SyncTest do

alias Ecto.Changeset

@doc """
Some clauses defined seem difficult or impossible to reach so their tests were ommitted
- {:error, :validation_error_on_syncing_installation, Changeset.t()}
- {:error, :validation_error_on_marking_installation_processed, Changeset.t()}
- {:error, :unexpected_transaction_outcome, any}
However, if these clauses can be caused by some updates upstream we should cover them with tests
"""
describe "installation_event" do

@payload load_event_fixture("installation_created")

test "syncs_correctly_with valid data" do
Expand All @@ -48,8 +56,16 @@ defmodule CodeCorps.GitHub.SyncTest do

{:error, :multiple_unprocessed_installations_found} = Sync.installation_event(@payload)
end

test "fails on syncing api error" do
with_mock_api(CodeCorps.GitHub.FailureAPI) do
assert {:error, :github_api_error_on_syncing_repos, _error} = Sync.installation_event(@payload)
end
end
end



describe "installation_repositories_event/1 added" do
@payload load_event_fixture("installation_repositories_added")

Expand Down

0 comments on commit e960094

Please sign in to comment.