View Source Igniter.Test (igniter v0.3.39)

Tools for testing with igniter.

Summary

Functions

Fakes applying the changes of an igniter.

Applies an igniter, raising an error if there are any issues.

IO.puts the current igniter diff, and returns the igniter

Sets up a test igniter that has only the files passed to it.

Functions

@spec apply_igniter(Igniter.t()) ::
  {:ok, Igniter.t(),
   %{
     tasks: [{String.t(), [String.t()]}],
     warnings: [String.t()],
     notices: [String.t()]
   }}
  | {:error, [String.t()]}

Fakes applying the changes of an igniter.

This function returns any tasks, errors, warnings.

@spec apply_igniter!(Igniter.t()) :: Igniter.t() | no_return()

Applies an igniter, raising an error if there are any issues.

See apply_igniter/1 for more.

Link to this macro

assert_creates(igniter, path, content \\ nil)

View Source (macro)
Link to this macro

assert_has_patch(igniter, path, patch)

View Source (macro)
Link to this macro

assert_unchanged(igniter)

View Source (macro)
Link to this macro

assert_unchanged(igniter, path_or_paths)

View Source (macro)
Link to this function

puts_diff(igniter, opts \\ [])

View Source
@spec puts_diff(Igniter.t(), opts :: Keyword.t()) :: Igniter.t()

IO.puts the current igniter diff, and returns the igniter

Options

  • label - A label to put before the diff.
  • only - File path(s) to only show the diff for
Link to this function

test_project(opts \\ [])

View Source
@spec test_project(opts :: Keyword.t()) :: Igniter.t()

Sets up a test igniter that has only the files passed to it.

Starting point

All of the files of an empty mix project are added by default. You can specify more or overwrite the default files by passing a map of file paths to their contents.

Limitations

You cannot install new dependencies, or use dependencies your own project does not have. If you need to do that kind of thing, you will have to do a test that uses tools like System.cmd in a temporary directory.

Options

  • files - A map of file paths to file contents. The file paths should be relative to the project root.
  • app_name - The name of the application. Defaults to :test.

Examples

test_project(files: %{
  "lib/foo.ex" => """
  defmodule MyApp.Foo do
    use Ash.Resource
  end
  """
})