Skip to content

contract testing adr#808

Merged
jumboduck merged 4 commits intomainfrom
contract-testing-adr
Apr 23, 2026
Merged

contract testing adr#808
jumboduck merged 4 commits intomainfrom
contract-testing-adr

Conversation

@jumboduck
Copy link
Copy Markdown
Contributor

  • chore: rename smoke test targets to contract test targets
  • docs: add ADR for fakes and contract tests pattern

jumboduck and others added 2 commits April 22, 2026 13:50
Rename `test_smoke_aws` → `test_contract_aws` and `test_smoke_github` →
`test_contract_github` to use consistent "contract test" terminology
throughout the Makefile and TODO.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Documents the decision to use in-memory fakes and contract tests to
decouple the main integration test suite from live external services,
first introduced for AWS Lambda (#763) and extended to GitHub (#807).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 22, 2026

Claude finished @jumboduck's task in 1m 47s —— View job


PR Review: Contract Testing ADR

  • Run static analysis (build, vet, mod tidy)
  • Review changed files
  • Post review feedback

Static Analysis

All checks pass — go build, go vet, and go mod tidy are clean.

Review

Overall: This is a well-written ADR that clearly documents the fakes + contract tests pattern. The Makefile rename from test_smoke_* to test_contract_* is clean and complete — no stale references to the old names remain anywhere in the repo (checked across all .yml, .yaml, .md files and the Makefile itself).

ADR quality: The document is well-structured and follows the existing ADR format established by the other two ADRs in docs/adr/. The Context section clearly motivates the problem, and the Decision section gives a concrete, numbered recipe that someone new to the codebase can follow. The "interface abstraction level" and "contract tests vs main integration suite" sections add good nuance.

Two minor suggestions posted as inline comments:

  1. ADR step ordering (docs/adr, line 34): Steps 3 and 4 introduce the fake after referencing it — swapping them would read more naturally.
  2. TODO.md consistency (line 102): Two TODO items still say "Trim … to smoke tests" after the rename to contract tests.

What's done well:

No bugs, security issues, or functional concerns — this is a docs + build target rename PR and it's clean.

Comment thread docs/adr/20260421-fakes-and-contract-tests.md
Comment thread docs/adr/20260421-fakes-and-contract-tests.md Outdated
Comment thread docs/adr/20260421-fakes-and-contract-tests.md
- Add 'who can run the tests' as a third problem in Context (Jon's comment)
- Clarify that the shared contract function runs against both fake and real
  adapter — this is the mechanism that guarantees they behave identically
  (Tooky's comment)
- Expand Consequences to reflect the contributor access improvement

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jumboduck jumboduck marked this pull request as ready for review April 23, 2026 09:17
Comment thread Makefile
test_contract_aws: ensure_gotestsum ## Run AWS contract tests against real AWS (requires AWS creds)
@echo "Running AWS contract tests against real AWS..."
@echo "Requires AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to be set"
@$(GOTESTSUM) -- -v -p=1 -run "LambdaContract_RealAWS|AWSTestSuite/TestGetLambdaPackageData|AWSTestSuite/TestGetEcsTasksData|AWSTestSuite/TestGetS3Data" ./internal/aws/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The AWSTestSuite/TestGetLambdaPackageData|AWSTestSuite/TestGetEcsTasksData|AWSTestSuite/TestGetS3Data tests included here aren't contract tests in the same sense as LambdaContract_RealAWS — they're integration tests that happen to hit real AWS. This is fine as a pragmatic aggregation target, but the target name test_contract_aws and help text "Run AWS contract tests" may be misleading once ECS and S3 get their own proper contract test suites (per TODO.md). Worth keeping in mind for the future, no action needed now.

@jumboduck jumboduck dismissed JonJagger’s stale review April 23, 2026 09:19

Change accepted and done.

@jumboduck jumboduck enabled auto-merge (squash) April 23, 2026 09:20

2. **Write a shared contract test function** that asserts the key behavioural properties of the interface — what fields are present, what error behaviour to expect, and how edge cases are handled.

3. **Run the contract tests against both implementations**: the shared contract test function is invoked twice — once against the fake (in the regular test suite, no credentials required) and once against the real service (env-gated, called from `make test_contract`). Running the same suite against both is what guarantees they behave identically.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steps 3 and 4 read a bit out of order — step 3 talks about running contract tests against both implementations including the fake, but the fake isn't introduced until step 4. Consider swapping the order (build the fake first, then describe how the contract tests run against both) so a reader encountering this for the first time doesn't have to read ahead.

Suggested change
3. **Run the contract tests against both implementations**: the shared contract test function is invoked twice — once against the fake (in the regular test suite, no credentials required) and once against the real service (env-gated, called from `make test_contract`). Running the same suite against both is what guarantees they behave identically.
3. **Build an in-memory fake** that satisfies the same interface and passes the same contract tests. The fake is the only implementation used in the main integration test suite.
4. **Run the contract tests against both implementations**: the shared contract test function is invoked twice — once against the fake (in the regular test suite, no credentials required) and once against the real service (env-gated, called from `make test_contract`). Running the same suite against both is what guarantees they behave identically.

Comment thread TODO.md
@@ -100,7 +100,7 @@
- [ ] Fake-backed unit tests for orchestration (concurrent cluster/service/task fetching, error propagation)
- [ ] `NewECSClientFunc` factory + inject fake into `snapshotECS_test.go` command tests
- [ ] Trim existing ECS integration tests to smoke tests
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TODO items at lines 102 and 112 still say "Trim existing … integration tests to smoke tests". Now that the Makefile targets have been renamed from test_smoke_* to test_contract_*, should these also say "contract tests" for consistency?

@jumboduck jumboduck merged commit 5756662 into main Apr 23, 2026
16 checks passed
@jumboduck jumboduck deleted the contract-testing-adr branch April 23, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants