Skip to content

Instantly share code, notes, and snippets.

@myers
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save myers/9122856 to your computer and use it in GitHub Desktop.

Select an option

Save myers/9122856 to your computer and use it in GitHub Desktop.

Revisions

  1. myers revised this gist Feb 20, 2014. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions gistfile2.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    1) test create new session (SessionHerderTest)
    ** (MatchError) no match of right hand side value: {:error, {:already_started, #PID<0.117.0>}}
    stacktrace:
    test/session_herder_test.ex:6: SessionHerderTest.__ex_unit_setup_0/1
    test/session_herder_test.ex:1: SessionHerderTest.__ex_unit__/2
  2. myers created this gist Feb 20, 2014.
    29 changes: 29 additions & 0 deletions gistfile1.ex
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    defmodule SessionHerderTest do
    use ExUnit.Case

    setup do
    {:ok, sup_pid} = Chat.SessionSupervisor.start_link
    {:ok, herder_pid} = Chat.SessionHerder.start_link
    {:ok, pids: [sup_pid, herder_pid]}
    end

    teardown config do
    IO.puts inspect(config[:pids])
    Enum.each config[:pids], &:erlang.exit(&1, :kill)
    :ok
    end

    test "create new session" do
    {:ok, session_id} = Chat.SessionHerder.new
    assert is_binary(session_id)
    assert Chat.SessionHerder.count == 1
    end

    test "reconnect old session" do
    {:ok, session_id} = Chat.SessionHerder.new
    assert is_binary(session_id)
    assert Chat.SessionHerder.count == 1
    :ok = Chat.SessionHerder.reconnect(session_id)
    end

    end