Skip to content

test: after transaction#398

Merged
zachdaniel merged 2 commits intomainfrom
test/after-transactin
Jan 28, 2026
Merged

test: after transaction#398
zachdaniel merged 2 commits intomainfrom
test/after-transactin

Conversation

@barnabasJ
Copy link
Copy Markdown
Contributor

Summary

Add comprehensive tests for after_transaction callback behavior in GraphQL mutations.

Description

Tests verify that after_transaction hooks are properly invoked for all mutation types (create, update, destroy) in
both success and error scenarios.

Depends on: ash-project/ash#2532

Test Coverage

Action Type Success Error Rollback Verification
Create ✅ (Mnesia only)
Update ✅ (Mnesia only)
Destroy ✅ (Mnesia only)
  • ETS tests (6): Verify callbacks fire with correct result tuples
  • Mnesia tests (9): Same as ETS plus rollback verification (Mnesia has real transactions)

Test Infrastructure

  • AfterTransactionChange: Sends {:after_transaction, action_name, result} to test process
  • AfterActionErrorChange: Simulates after_action errors for rollback testing
  • AfterTransactionEts / AfterTransactionMnesia: Test resources with success/error action variants

Test Plan

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

Add test infrastructure for verifying after_transaction callbacks
are properly invoked on GraphQL mutations:

- AfterTransactionChange: sends message to test process on transaction completion
- AfterActionErrorChange: simulates after_action errors for rollback testing
- AfterTransactionEts: ETS-based resource with success/error action variants
- AfterTransactionMnesia: Mnesia-based resource for real transaction testing
Verify after_transaction callbacks fire correctly for all mutation types:

ETS tests (6 tests):
- Create/update/destroy success: callback receives {:ok, result}
- Create/update/destroy error: callback receives {:error, error}

Mnesia tests (9 tests):
- Same success/error tests as ETS
- Rollback verification: records not persisted when after_action fails
  (Mnesia supports real transactions unlike ETS)
@barnabasJ barnabasJ changed the title Test/after transactin test: after transaction Jan 26, 2026
@barnabasJ barnabasJ self-assigned this Jan 26, 2026
@zachdaniel zachdaniel merged commit 73f73c1 into main Jan 28, 2026
21 of 22 checks passed
@zachdaniel
Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

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.

2 participants