Storehouse.Test (Storehouse v0.2.0)

Copy Markdown View Source

Assertions on the files a test stored, with Storehouse.Memory:

import Storehouse.Test

test "an avatar is stored, and the old one deleted", %{user: user} do
  {:ok, user} = Accounts.update_avatar(user, upload)

  assert_stored user.avatar.key
  refute_stored "avatars/old.png"
  assert [%{key: "avatars/" <> _}] = stored_files()
end

Each sees only the files of the calling test (see Storehouse.Memory's checkout).

Summary

Functions

Asserts that a file is stored under key, or under a key that matches a regex. Gives the key.

Asserts that no file is stored under key, or under a key that matches a regex.

The files stored, in the order of their keys: each with its :key, :body, :content_type and :modified_at.

Functions

assert_stored(pattern)

@spec assert_stored(String.t() | Regex.t()) :: String.t()

Asserts that a file is stored under key, or under a key that matches a regex. Gives the key.

refute_stored(pattern)

@spec refute_stored(String.t() | Regex.t()) :: :ok

Asserts that no file is stored under key, or under a key that matches a regex.

stored_files()

@spec stored_files() :: [map()]

The files stored, in the order of their keys: each with its :key, :body, :content_type and :modified_at.