Caravela.Gen.RestControllerTest (Caravela v0.13.3)

Copy Markdown View Source

Generates ExUnit tests for every :rest entity's Phoenix controller. One test file per entity, one describe per action, one test per happy/unhappy path. Uses the standard Phoenix.ConnTest stack and assumes *.ConnCase under test/support/conn_case.ex.

Tests are CI-ready: mix test picks them up, no extra configuration required beyond the consumer app's existing Phoenix test setup. Fixture hooks are marked # TODO: because the generator can't infer the app's factories.

Returns a list of {path, source} tuples. Custom code below the # --- CUSTOM --- marker is preserved on regeneration.

Summary

Functions

Generate a test file per :rest entity in the domain.

Generate a single entity's controller test file.

Path to the generated controller test file.

Functions

render_all(domain, opts \\ [])

@spec render_all(
  Caravela.Schema.Domain.t(),
  keyword()
) :: [{String.t(), String.t()}]

Generate a test file per :rest entity in the domain.

render_entity(domain, entity, opts \\ [])

Generate a single entity's controller test file.

test_file_path(domain, entity)

Path to the generated controller test file.