# `MishkaCmsCore.Dev.TeardownTestSeed`
[🔗](https://github.com/mishka-group/mishka_cms_core/blob/v0.0.1/lib/mishka_cms_core/dev/teardown_test_seed.ex#L5)

Disposable dev fixture for verifying the Site permanent-delete teardown
(`MishkaCmsCore.Runtime.Workers.SiteTeardownWorker`).

It builds a throwaway site `teardown-test` whose layout, error page, pages and
components are all `precompile: true`, so their runtime modules are compiled
into memory — giving the teardown something real to free. Your normal seeded
sites (e.g. `localhost`) are the untouched control.

Built on `MishkaCmsCore.Dev.Generator`, the same generators the dev seeds use.

## How to run

Run inside a live server so Oban actually compiles the modules:

    iex -S mix phx.server

    # 1. create the fixture — returns the site + its loaded module names
    %{modules: mods} = MishkaCmsCore.Dev.TeardownTestSeed.create()

    # 2. confirm the modules are in RAM — every entry should be {_, true}
    MishkaCmsCore.Dev.TeardownTestSeed.module_status(mods)

    # 3a. realistic path: in the admin, ARCHIVE then PERMANENTLY DELETE
    #     `teardown-test` (master user). Archiving keeps RAM; permanent-delete
    #     frees it.
    #
    # 3b. or skip the UI entirely:
    MishkaCmsCore.Dev.TeardownTestSeed.destroy()

    # 4. confirm RAM was freed — every entry should now be {_, false}
    MishkaCmsCore.Dev.TeardownTestSeed.module_status(mods)

`true -> still true after archive -> false after permanent-delete` proves the
teardown frees live RAM. The teardown also wipes the site's cached CSS/JS and
routing; see the `[SiteTeardownWorker] purged ...` log line.

Re-running `create/0` while the fixture still exists raises; call `destroy/0`
(or delete it in the admin) first.

# `activate`

Activates the fixture site — recompiles its parts. Returns `:ok` / `:not_found`.

# `create`

Creates the `teardown-test` site with precompiled content, waits for the
runtime modules to compile, and returns `%{site: site, modules: [module]}`.

# `deactivate`

Deactivates the fixture site — purges its parts. Returns `:ok` / `:not_found`.

# `destroy`

Permanently deletes the `teardown-test` site (cascade), triggering the
teardown — a shortcut for the admin archive + permanent-delete flow. Returns
`:ok`, or `:not_found` when the active fixture is absent.

# `module_status`

Returns `[{module, loaded?}]` for the captured module list.

# `modules`

Recomputes the current module names from the DB under the site's current name.
Use after `rename/1` (the names captured by `create/0` point at the old name).
Returns `[]` when the fixture is absent.

# `rename`

Renames the fixture site to `new_name` — purges the old-name parts and
recompiles under the new name. Returns `:ok` / `:not_found`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
