Ash.Test (ash v3.5.25)
View SourceTesting helpers for Ash.
Summary
Functions
Assert that the given changeset, query, or action input has a matching error.
A macro for comparing Ash resources while ignoring metadata differences.
Refute that the given changeset, query, or action input has a matching error.
Clears the __metadata__
field and the underlying ecto __meta__
field
Functions
Assert that the given changeset, query, or action input has a matching error.
Use the optional second argument to assert that the errors (all together) are of a specific class.
A macro for comparing Ash resources while ignoring metadata differences.
Overview
Ash resources contain metadata fields (__metadata__
and __meta__
) that track internal state like
loaded relationships and action history. These fields can cause equality comparisons to fail even
when the actual data is identical. This macro uses strip_metadata/1
to remove these fields before
comparison.
Usage
Use when comparing resources that have gone through different processing paths, such as comparing seeded data with data that has been processed through resource actions.
Supported Operators
==
and===
- Equality comparison!=
and!==
- Inequality comparisonin
andnot in
- Membership testing
Examples
# Compare resources
assert_stripped user1 == user2
assert_stripped [user1, user2] === [user3, user4]
assert_stripped user1 in [user2, user3, user4]
assert_stripped user1 not in [user2, user3, user4]
Refute that the given changeset, query, or action input has a matching error.
The error_class
argument has been deprecated and should not be used.
Clears the __metadata__
field and the underlying ecto __meta__
field
This allows for easier comparison of changeset/query results