agentleFS
RostislavDuginRostislavDugin/postgresus/.agents/skills/testing/SKILL.md

testing

Skill9.3k starsChanged 5 days agoApache-2.0View on GitHub

Write, change, run and review tests in Databasus. Covers how to name a test, which layer it belongs to, how to prepare data through the API, when a unit test or a fake is allowed, how to wait for a condition, and which tests to run before handing work over. Use when writing, changing, running or reviewing tests, when fixing a bug, and when choosing which test commands a change runs.

194 other projects use a version of this.

Trending

Quiet since July.thin dataabout the whole repository

Dec 2025: 4 mentionsJan 2026: 1 mentionFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 1 mentionAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the RostislavDugin/postgresus repository that our weekly crawl found: only 10 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

Most recently taken up by

Who's talking about RostislavDugin/postgresus

The biggest 5 of 10 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 10

Talked about on GitHub and Bluesky (10 times).

On GitHub · 7

2 more on GitHub

Used with

Projects with it also use bundle-dependency-prs, update-library-template and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • MicrosoftSkill

    bundle-dependency-prs

    Fix broken dependency update PRs and aggregate the ones that work into one PR.

    Also in 7 projects that use this

  • MicrosoftSkill

    update-library-template

    Merges the latest Library.Template into this repo (at position of HEAD) and resolves conflicts.

    Also in 7 projects that use this

  • zetaloopSkill

    assign-copilot

    Assigns a GitHub issue to the Copilot coding agent, optionally specifying a custom agent. Use this when asked to assign an issue to Copilot or delegate an issue to CCA.

    Also in 3 projects that use this

  • NVIDIA-NeMoSkill

    build-and-dependency

    Dev environment setup for Megatron Bridge — container-based development, uv package management, lockfile regeneration, adding dependencies, Slurm container usage, and common build pitfalls.

    Also in 3 projects that use this

  • timmo001Skill

    changeset-scope

    Keep all scoped code work contained to the user-defined changeset. Use for implementation, fixes, diagnosis, refactoring, cleanup, and review when explicit instructions, named files, diffs, branches, pull requests, or injected work scopes define the boundary.

    Also in 3 projects that use this

  • JetBrainsSkill

    module-dependencies

    Add or modify IntelliJ module dependencies in `.iml` files.

    Also in 3 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. 0 are common, 8 are distinctive, and 6 are very specific to this project.

  • 0

    Common

    Most of the 173 edited versions we read keep these.

  • 8

    Distinctive

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Test what a caller observes: an HTTP operation, an engine against a real server, or a screen.

    line 12
  2. Distinctive:

    Never mock our own database, modules or services.

    line 13
  3. Distinctive:

    Run every test you wrote or changed and see it pass.

    line 15
  4. Very specific:

    Call operations through the client from apptest, which checks every response against the contract.

    line 65
  5. Distinctive:

    Create data through the API.

    line 66
  6. Distinctive:

    Use the real screen and domain APIs.

    line 78
  7. Distinctive:

    Prefer user-event and accessible role/name queries.

    line 82
  8. Very specific:

    Write a unit test without the application only for pure logic that has no HTTP entry point or is too slow to enumerate through HTTP.

    line 90
  9. Very specific:

    Test a client of an external system against a real local substitute where one exists.

    line 97
  10. Very specific:

    Write fakes as small hand-written structs.

    line 99
  11. Very specific:

    Never wait for a fixed time.

    line 103
  12. Distinctive:

    When the behavior depends on time, move the test clock.

    line 105
  13. Very specific:

    Call testdb.Open(t) once per test.

    line 110
  14. Distinctive:

    After you interrupt a run, remove only what that run left behind.

    line 119

“Common” is measured: kept by at least 6 in 10 of the 173 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Testing

docs/testing.md describes the kinds of tests, how they are isolated and how runs work. This skill says how to write one test.

The main rules

  • Test what a caller observes: an HTTP operation, an engine against a real server, or a screen. Internal functions are covered through that surface.
  • Never mock our own database, modules or services. A module's test builds the real modules it depends on.
  • A bug fix starts with a test that reproduces the bug. Run it on the unfixed code and see it fail for the reason the bug describes, then fix the code and see it pass.
  • Run every test you wrote or changed and see it pass. A package that only compiled has not passed; say so in the report.

Names

A test name has two parts: what is tested and the scenario.

  • The Go function names what is tested, in Go style: TestCreateStorage, TestRestoreBackup.
  • Each scenario is a sentence in t.Run, even when the function has only one scenario. The sentence is lowercase, has no period and uses the present tense. It states the result first, then the condition, which starts with when, with, without, after or before.
func TestDeleteStorage(t *testing.T) {
	t.Parallel()

	t.Run("deletes storage when no backup uses it", func(t *testing.T) {
		t.Parallel()
		// ...
	})

	t.Run("returns 409 when a backup is stored in it", func(t *testing.T) {
		t.Parallel()
		// ...
	})
}

A table test puts the sentence into the name field. In Vitest, describe names the component or page and it holds the sentence. Variables inside a test are named after the domain, such as createdStorage or secondMember. Never name them got, want, result or data. expectedStatus in a case table is fine.

Module API tests

A module's tests live in its root directory in package <module>_test and reach the module only through its HTTP operations.

func TestGetStorage(t *testing.T) {
	t.Parallel()

	t.Run("returns 404 when storage belongs to another workspace", func(t *testing.T) {
		t.Parallel()
		app := apptest.New(t)
		owner := app.SignUp(t)
		stranger := app.SignUp(t)
		storage := owner.CreateLocalStorage(t, owner.CreateWorkspace(t))

		response, err := stranger.Client.GetStorageWithResponse(t.Context(), storage.Id)

		require.NoError(t, err)
		require.Equal(t, http.StatusNotFound, response.StatusCode())
	})
}
  • Call operations through the client from apptest, which checks every response against the contract. Use a raw http.Client only for a request the contract cannot describe, such as malformed JSON.
  • Create data through the API. Direct SQL is allowed only for a state the API cannot create, for data the API does not return, and to clean up outside the test's own database.
  • Extract a helper as soon as a second test repeats the same setup.
  • Cover every operation for these cases:
    • the successful case;
    • invalid input;
    • a request without a session;
    • a request from a member of another workspace, or from a member whose role is too low;
    • conflicts of state, such as deleting a storage that holds backups or creating a duplicate.
  • A background job does not run on its own in the test application. Run its pass explicitly, and move the clock instead of waiting for the schedule.

Frontend screen tests

Use the real screen and domain APIs; replace only their HTTP boundary. Use the frontend test lifecycle and its existing renderer and typed response helpers instead of assembling substitute providers or mocking our services.

  • Select happy-dom only for tests that need a document. Keep pure algorithms, API calls and architecture fixtures in node.
  • Declare each request's explicit method and finite pathname. Do not hide dependencies behind blanket handlers or silence unexpected-request failures.
  • Prefer user-event and accessible role/name queries. Select the locale, theme and router entry the scenario needs through the renderer; use the app-level wrapper for complete-app tests.
  • Hold overlapping work with controlled responses and release each response explicitly. Advance fake clocks only for time-dependent behavior, and wait for an observable processing signal before asserting that no further request, state update or error occurs.
  • Cover reset, stale success/error, unmount and setup-cleanup-setup when changing an asynchronous hook. Verify timer and listener cleanup and callbacks that use the latest options.
  • Prove harness failures through an isolated runner, checking both nonzero exit and the intended diagnostic. Remove temporary files and terminate child processes on timeout or failure.
  • Unmount before pending responses settle. Restore every global override and browser state the test changes; do not rely on the next test to repair them. A failed test receives the same cleanup.

Unit tests and fakes

Write a unit test without the application only for pure logic that has no HTTP entry point or is too slow to enumerate through HTTP. docs/testing.md lists examples.

A fake replaces only:

  • an external system we cannot run locally, behind an interface in Deps, such as a third-party HTTP API;
  • a failure that is unsafe to cause for real, such as a full disk or a connection cut in the middle of an upload.

Test a client of an external system against a real local substitute where one exists. Use Mailpit for SMTP, MinIO, Azurite and SFTP containers for storages, and an httptest.Server for HTTP APIs.

Write fakes as small hand-written structs. Do not use mock generators, testify/mock or testify/suite. Use require for what the rest of the test depends on and assert for independent fields.

Waiting

  • Never wait for a fixed time. Wait for the condition with testwait.Until, which allows two minutes. Only a test that exists to observe a long period of real time, or a container start-up wait, states a longer limit with testwait.Within(limit). Never use time.Sleep or Eventually.
  • For a negative check, such as "no notification was sent", first wait for a sign that the action was processed. Then watch the check's window.
  • When the behavior depends on time, move the test clock.
  • In Vitest, wait with findBy*, waitFor or, under fake timers or without a document, waitForCondition from shared/lib/test/conditionWait. Never pass a time limit to one wait or one test; the shared limits only bound a hung test. A slow wait is a race to fix: assert what the screen keeps showing, not a state a poll can replace.

Isolation

  • Call testdb.Open(t) once per test. A helper that opens one database for several subtests makes that database shared again.
  • On a shared engine server, give every object a unique name: database, role, schema and replication slot.
  • Take ports from 127.0.0.1:0 and files from t.TempDir(). Remove every container or process the test starts in t.Cleanup.
  • Mark independent tests and their subtests with t.Parallel(). A subtest stays sequential only with a stated reason, in //nolint:tparallel // <reason> on its test: a shared application, moving clock, source server, engine-version fixture or process environment setting, or a dependency on an earlier subtest.

Which tests to run

Check a change as docs/testing.md says, and include the command and its result in the report. While fixing a test it reported, repeat that test directly with the Go test command or pnpm test -t in frontend/. A race reported by CI is reproduced by adding -race to the Go test command, because local runs leave it out. docs/testing.md gives the full commands.

After you interrupt a run, remove only what that run left behind. Never prune Docker or stop the shared test PostgreSQL server, apart from its recovery after a crash.

Before handing the work over

  • Each test names what it tests and describes its scenario in a sentence.
  • New behavior is covered at the right layer.
  • Data is prepared through the API. Direct SQL appears only where nothing else works.
  • Nothing of ours is mocked, and no test sleeps.
  • The tests you touched ran and passed, and the report shows the commands.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.