Skip to content

ADR: Automated tests never touch a real database or permanent storage

ADR: Automated tests never touch a real database or permanent storage

Status: accepted, 2026-11-20, at 1.0.5.131. Steve set the rule in two steps: on 18 November, "Generally speaking automated tests should never make permanent changes to data" and "when possible use a mock database"; on 19 November, "all of our tests should use mock when they can ideally automated tests never touch the databases or permanent storage". This record is ADR-141.

Reading list

  1. ADR: The gate runs where the memory is: its addendum of 1.0.5.94 moved the gate's Cosmos DB passes onto the emulator, the first step of this rule.
  2. ADR: A second store on Cosmos DB, and what it costs: why the store tests fail, never skip, when no store is named.
  3. ADR: The rules a change has to pass: the table this rule's test is listed in.

In plain words

A test proves the code, not the world. So a test reads and writes a stand-in: first a fake of the port the code talks to, held in memory; and only when a fake cannot prove what is being tested, a store born with the run and thrown away with it. It never reads or writes the database the sites read, a storage account, the job-hunt share, Gmail, or anyone else's service. A test that did would leave rows behind, spend the live account's throughput while visitors are on it, and turn red when the world changes rather than when the code does.

Context

Until 1.0.5.94 the gate ran its Cosmos DB passes on the live account's tests- containers. Each pass spent about 950 RU/s of a 1,000 RU/s database the sites share, brought thousands of 429s to every gate window, and left 1.98 million test documents (2.56 GB) in tests-logs. 1.0.5.94 moved those passes onto the Cosmos DB emulator, a container started beside the gate's job and gone when it ends. Steve's words above widened that from the gate to every automated test.

An audit on 19 November (code1118e, read only) read every xUnit, Vitest, Playwright and Functions test for what it touches. Nearly all of them already use a fake: the API's test hosts boot a scratch SQLite file and delete it, every outside reader in a test is routed to a recorded answer, the Playwright specs run against a local server, and the Functions and server suites read and write in-memory shares and a scripted Gmail. Three places did not hold, and they are listed below.

Decision

  1. Mock first. A unit or handler test uses an in-memory fake of the port: the repository, the store, the blob, the share, Gmail, Hunter, LinkedIn. That is the default for every new test.
  2. A throwaway store only when a fake cannot prove it. A test that must prove a store's own behavior (a query, an index, paging, a transaction) runs on a store born and thrown away with the run: SQLite in memory or in a temp file, or the Cosmos DB emulator container. It says why in one line.
  3. Never the live ones. No automated test reads or writes cosmos-theyard-ss, the Azure SQL database, any storage account (stjobhuntss included), the job-hunt share, Gmail, or any outside API. A read after a roll is a smoke check of production, not a test, and writes nothing.
  4. A new test that breaks this is a defect and does not ship. The exceptions that exist today are listed here with a plan each; none is added.

The exceptions, and the plan for each

Where What it touches Plan
CosmosKeysetTests (api/TheYard.Tests) Reads the live catalogue once in the gate's cosmos job, about 2,000 RU, to hold a deep page under 100 RU; the emulator reports no request units. Read only. Seed a catalogue on the emulator (scripts/cosmos_emulator.mjs), keep the test's row-equality and no-OFFSET checks there, and hold the cost by the query the store's log shows rather than by request units. Then the cosmos job drops azure/login and the gate environment, and GateWorkflowTests stops pinning the one live address.
CosmosLive (api/TheYard.Tests/CosmosStoreTests.cs), shared by the store tests Writes. In the gate it is the emulator; on a laptop it was whatever Cosmos__AccountEndpoint named, and nothing stopped that being the live account. Done in this version: it refuses any address that is not this machine, and its credential defaults to the emulator's.
ParityTests and TextAppendMergeTests (functions/jobhunt.Tests) Read a copy of the real tracker CSV and markdown files named by PARITY_DATA and PARITY_MD_DATA, on a Windows laptop only; unset, they return without running. Never in the gate. Replace them with a synthetic tracker checked in beside the tests (the Seed helper already builds the edge rows), and keep the PowerShell comparison as a tool run by hand, not a test.

What holds it

TestsTouchNoLiveStoreTests: the store fixture refuses a non-loopback address (planted: the live account's address, refused by name); no test file opens a Cosmos DB store but the guarded fixture and the listed exception; and every share or blob client a test builds rides a fake transport. Planted before the guard: an unguarded fixture failed two of the three. The gate's own workflow is held by GateWorkflowTests (one live address in the gate, the keyset read's, and azure/login in no other job).

Consequences

  • A test's red means the code changed, not the account, the share or a mailbox.
  • The gate spends none of the live account's throughput but the one listed read, and leaves nothing behind.
  • What stops being true: a laptop run with a live endpoint set could write the account's tests- containers. It now stops before a client is made.
  • What stays true: the store tests fail, never skip, when no store is named; a smoke read of production after a roll is still how the live sites are checked.

Where it sits

Outside the rings: a rule over the test suites, held by a test that reads them, beside the rules in ADR-075's table.

Files

Enforced by

One rule in the rulebook cites this record, each held by a test on every release.

The rule What holds it In the last gate
No automated test reads or writes a real database or permanent storage: the store tests' one fixture refuses any address that is not this machine, no test opens a Cosmos DB store but that fixture and the one listed exception, and every share or blob client a test builds rides a fake transport TestsTouchNoLiveStoreTests 6 of 6 passed
Store

The Yard, home

Steven StoutStaff .NET engineerRemote

Production .NET that stays up. Built with AI, measured on every version.

Steven Stout

Hi, I'm Steve. I build the systems that make delivery boring in the best way, then coach people inside them.

  • 200+

    production releases, none took the platform down

    Conway Investment Research, 2019 to 2024. Sole engineer for the first three years on a live financial advisory platform.

    See how
  • 50%

    shorter release cycle

    Storee Construction, 2024 to 2026. Four ASP.NET applications onto one .NET 10 platform on Azure, with a four-person team I hired and mentored.

    See how

01Verified

Steven Stout

A real person, and the work is mine.

  • Identity

    Checked by LinkedIn, not by me.

    LinkedIn verified my government ID.

  • Running system

    You are looking at it.

    Version 1.0.5.273 is live. Nothing ships unless it passes the automated gates first.

That's who I am. Here's how I work.

02Strengths

Ten strengths, each with the proof beside it. The numbers match my resume and LinkedIn, and the live ones are read from this site as you look.

  • 01

    Keeps production alive

    200+ releases on a live financial platform, and none took it down. Sole engineer for the first three years.

    See the Conway work

  • 02

    Simplifies messy systems

    Four ASP.NET applications onto one .NET 10 platform on Azure, and a release cycle 50% shorter.

    See the Storee work

  • 03

    Marries dev and infrastructure

    Blue-green releases at Storee that flipped in about 5 seconds with nobody signed out, and Azure Front Door at two employers.

    See this site's cloud

  • 04

    Designs data that holds up

    White-label clients on one shared database, the isolation built into the data, and no cross-client issues.

    See the Conway work

  • 05

    Keeps AI-written code honest

    15 quality numbers that may only improve: 273 releases in a row with none worse.

    See the quality numbers

  • 06

    Resourceful

    $30,000+ cut from Azure and vendor spend at Conway. This site's Azure bill is public, resource by resource.

    See the bill

  • 07

    Builds people up

    Hired and mentored a four-person team. 13 colleagues recommend me by name.

    Read the recommendations

  • 08

    Takes ideas to production

    This site: designed, built and run solo, with 352 versions measured through one gate.

    How it was built

  • 09

    Writes clearly

    Posts on real engineering problems, in plain words.

    Read the blog

  • 10

    Owns decisions

    153 decision records, each with its tradeoff and the call I made.

    See the decision records

Built with AI. Gated so quality never slides.

Steven Stout’s showcase: a used-vehicle auction on .NET and React, built and run by one engineer, live on Azure, with its decisions written down.

No quality number has gotten worse at any release since 1.0.5.1 on 10 November: 273 releases in a row.

One engineer, an AI agent and a gate that checks 15 quality numbers on every release. 352 versions measured, with every result public, the worst days included.

82 releases in the last 7 days, each through the same gate.

Async methods with no CancellationToken, may only fall

11091.0.3.1391.0.5.2731.0.4.115, the ratchet
Every number, on the Quality page

TheYard, right nowLive

Answering in

unread

02505007501,000

server time at p95, the usual five minutes of the last day.

Azure this month

unread

the bill, by resource, read from Azure. The Admin tab shows every line.

Since the last roll

unread

 

rolled in place by the pipeline, behind one gate.

People who have visited

unread

30 days agotoday

Scanners, my own tools' and my own reads left out.

03Start here

04Where teams are heading

How I see engineering with AI, and the setup on this site that backs it.

AI-augmented teams · Architecture and ownership

AI writes more of the code. Someone still has to own what ships.

Teams are going to be heavily AI-augmented. That moves the senior job toward architecture and technical ownership: deciding what to build in pieces small enough to verify, and owning what ships.

  • Task tracking will get automated too. Judgment stays human: seeing a design fail at scale before it does.
  • On this site the AI's first design held the whole catalogue in memory. I caught it when the App Service plan hit 82 per cent and moved the work to the store.

What the AI wrote, what I decided

07Tech stack

  •    
  •    
  •    

Read from the build, never typed by hand

What TheYard runs on

What we use, where it runs, its AWS twin, the version as built, and the file that proves it.

Cloud patterns, not one vendor: every Azure piece in this stack has a named AWS twin. Mapped, not yet run on AWS.

  • .NET 1114 projects
  • React 19.3TypeScript 7.0
  • Azure9 Bicep files
  • 11GitHub Actions workflows
The whole stack, with the file that proves each line

The last release the gate stopped was 1.0.5.258 on 2 December, at its browser 1 of 2 job.

08How it is built

09How it is run

10Who and why

Next step

11What has to work, where is it today, and what does success look like?

Book 20 minutes opens an email to me with those three questions in it, and I answer with a time.

Book 20 minutes

Your email app should have opened with this message. If it did not, copy it and send it from any mailbox.

Or message me on LinkedIn