# `ArchTest.Freeze`
[🔗](https://github.com/yoavgeva/arch_test/blob/v0.2.0/lib/arch_test/freeze.ex#L1)

Violation baseline ("freeze") support for gradual architectural adoption.

When a rule has existing violations that cannot be fixed immediately,
use `freeze/2` to record the current set of violations as a baseline.
Future test runs only fail on *new* violations not in the baseline.

## Usage

    test "legacy dependencies being cleaned up" do
      modules_matching("MyApp.**")
      |> should_not_depend_on(modules_matching("MyApp.Legacy.**"))
      |> freeze("legacy_deps")
    end

## Baseline files

Baselines are stored as text files (one violation key per line) in
the directory configured by:

    config :arch_test, freeze_store: "test/arch_test_violations"

The default store path is `test/arch_test_violations/`.

Commit these files to version control. To "unfreeze" and require all
violations to be fixed, delete the corresponding file.

## Updating the baseline

Run with `ARCH_TEST_UPDATE_FREEZE=true` to overwrite baselines with the
current violation set:

    ARCH_TEST_UPDATE_FREEZE=true mix test

# `freeze`

```elixir
@spec freeze(String.t(), (-&gt; :ok)) :: :ok
```

Runs `assertion_fn` and freezes violations against a stored baseline.

`rule_id` is used to name the baseline file (should be unique per rule).

Only violations **not** in the baseline cause test failure.
If `ARCH_TEST_UPDATE_FREEZE=true`, the baseline is updated to the current
violation set.

# `store_path`

```elixir
@spec store_path() :: String.t()
```

Returns the path to the freeze store directory.

# `update_freeze?`

```elixir
@spec update_freeze?() :: boolean()
```

Returns `true` if the `ARCH_TEST_UPDATE_FREEZE` environment variable is set.

---

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