August 2025
Intermediate to advanced
294 pages
6h 59m
English
Ash.Generator[128] provides tools for dynamically generating various kinds of data. You can generate action inputs, queries, and even complete resource records, without having to specify values for every single attribute. We can use Ash.Generator to clean up our test setup and to clearly distinguish our setup code from our test code.
The core functionality of Ash.Generator is built using the StreamData[129] library and the generator/1 callback on Ash.Type. You can test out any of Ash’s built-in types,[130] using Ash.Type.generator/2:
| | iex(1)> Ash.Type.generator(:integer, min: 1, max: 100) |
| | #StreamData<66.1229758/2 in StreamData.integer/1> |
| | iex(2)> Ash.Type.generator(:integer, min: 1, max: 100) |> ... |
Read now
Unlock full access