Condukt.SessionStore.Conformance (Condukt v3.0.0)

Copy Markdown View Source

Tests every Condukt.SessionStore has to pass, for use in a store's own test suite.

defmodule MyApp.RedisStoreTest do
  use ExUnit.Case, async: true
  use Condukt.SessionStore.Conformance, store: MyApp.RedisStore

  setup do
    prefix = "test:#{System.unique_integer([:positive])}"

    %{
      store_opts: [redix: MyApp.Redix, key: prefix <> ":a"],
      other_store_opts: [redix: MyApp.Redix, key: prefix <> ":b"]
    }
  end
end

The test module provides a setup that returns :store_opts and :other_store_opts: options for two distinct, empty sessions in the store, which the tests use to check that one session's state never shows up in the other's.

Pass journal: false for a store that only implements the snapshot callbacks. A store that implements the journal callbacks should pass the journal tests, since Condukt.Session relies on what they check to resume an interrupted run.