Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 582 Bytes

File metadata and controls

31 lines (22 loc) · 582 Bytes

CachexSandbox

Test isolation for Cachex. Each test gets its own clean cache.

Setup

# mix.exs
{:cachex_sandbox, "~> 0.1", only: :test}

# test/test_helper.exs
CachexSandbox.start([:my_cache])

Usage

use ExUnit.Case, async: true
use CachexSandbox.Case

test "isolated cache", %{caches: caches} do
  Cachex.put(caches[:my_cache], "key", "value")
  # Other tests won't see this
end

Your app reads the cache name from config:

def cache_name, do: Application.get_env(:my_app, :cache, :my_cache)