# `Tack.Credo.Check.TimestampRewriteInTest`
[🔗](https://github.com/giggleton/pica/blob/v0.1.0/dev/tack/credo/check/timestamp_rewrite_in_test.ex#L1)

## Basics

> #### This check is disabled by default. {: .neutral}
>
> [Learn how to enable it](`e:credo:config_file.html#checks`) via `.credo.exs`.

This check has a base priority of `high` and works with any version of Elixir.

## Explanation

A test that needs an old row moves its stamp with the suite's `backdate/3` helper
(`test/support/backdate.ex`), not an `update_all`.

`elixir-code-review`, `references/test-quality.md`:

> **Age a row with `backdate/3`, never a local `update_all`.** A test that places a row in
> time calls `backdate/3`: `{amount, unit}` always means "that long ago", the instant is
> truncated to the column's precision, and a query matching no rows fails.

Left alone, a suite grows one `backdate` helper per file, with incompatible signatures: some
add the offset and are called with a negative number, some subtract it; half truncate and
half do not; some return silently when nothing matched, so a test that backdated no row
asserts against fresh stamps and passes. Each new test copies whichever sits nearest.

This flags any `update_all` whose `set:` names a literal `*_at` key — the way every
timestamp column is named. A domain-named wrapper (`joined_at/2`, `move_expiry/2`) is fine
as long as its body calls `backdate/3`, which writes its keys dynamically and so is never
flagged itself. Scope the check to `test/` in `.credo.exs`; `lib/` writes `updated_at` in
bulk on purpose.

## Check-Specific Parameters

*There are no specific parameters for this check.*

## General Parameters

Like with all checks, [general params](`e:credo:check_params.html`) can be applied.

Parameters can be configured via the [`.credo.exs` config file](`e:credo:config_file.html`).

---

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