Testing an AI Git tool without buying an AI response for every test
Testing my Git assistant doesn’t need to buy an AI response for every test.
Most of the program’s behavior is ordinary application behavior: parse arguments, find a repository, obtain a diff, format a response, and either create a commit or show a preview. A live model call would add cost and another source of failure to checks that don’t need it.
The December test suite uses temporary Git repositories and Pydantic AI’s test model to keep those checks local.

Illustration: a controlled test has a different scope from the real thing.
A repository the test can change
The repository fixture creates a directory under pytest’s temporary path, initializes Git, supplies a test identity, and makes an initial commit. It changes into that directory for the test and restores the previous working directory afterward.
That gives the application an actual Git index and history to inspect without using the repository I’m working in.
The dry-run integration test stages a file, remembers the current HEAD, and runs the application with the test model. This excerpt shows its central assertion:
head_sha = test_repo.head.commit.hexsha
ret = run_app(["commit", "--model", "test", "--dry-run"])
assert ret == 0
assert test_repo.head.commit.hexsha == head_sha
The surrounding test also checks for the dry-run message in captured output. Success here means the preview path returns successfully without advancing HEAD. That is a useful behavior to check independently of how eloquent a generated commit message is.
A model boundary I can control
The agent fixtures also construct a TestModel with supplied output text and the same Message output type used by the application.
That fits the title/body contract. I can exercise the application’s handling of a structured result without asking a provider to generate new prose each time.
The CLI integration tests use --model test; the custom-output agent fixtures are a separate way the suite supplies controlled model behavior. Keeping those arrangements distinct matters when I want a test to assert exact message text rather than just successful execution.
The assertion still decides what the test proves
One positive commit test checks that HEAD has a message and that the application printed “Committed successfully.” That is weaker than checking that a new commit was created with the expected content. The fixture already created an initial commit with a message.
A test double doesn’t make a weak assertion stronger. I still need to choose observations that would fail if the intended behavior didn’t happen.
For dry runs, comparing HEAD before and after does that. For a new commit, I would also compare the revision and inspect the new message and changed files.
The local tests cover the tool around the model. To judge descriptions of unfamiliar diffs, I need a separate set of examples and a review of the live model’s output.