# `Alternera.Resource.Test.Samples`
[🔗](https://github.com/10e-ab/alternera-sdk/blob/v0.9.0/alternera_resource_sdk/lib/alternera/resource/test/samples.ex#L1)

Builds a valid record of any resource, for the contract kit and for tests.

The input for the primary create action comes from the attributes' types
and constraints: a string, a number inside its bounds, today's date, the
first of a `one_of` and so on. A required `belongs_to` gets a record of its
own, made first in the same tenant. A value the types cannot guess (a
string with a `match:` pattern, a custom type) comes from `samples`, a map
of resource module to the attributes that override the generated ones:

    Samples.create!(Finance.Currency, tenant, actor, %{Finance.Currency => %{code: "SEK"}})

A sample may also be a function of no arguments that returns the map,
called for each record: a resource with two required references to the
same parent needs two parents, and a parent with a unique attribute then
needs a new value each time.

# `create!`

```elixir
@spec create!(module(), String.t(), term(), map(), non_neg_integer()) ::
  Ash.Resource.record()
```

Creates a record of `resource` in `tenant` as `actor`, with its required parents.

# `input`

```elixir
@spec input(module(), map()) :: map()
```

The create input for `resource`, without its required parents.

# `input_with_parents!`

```elixir
@spec input_with_parents!(module(), String.t(), term(), map(), non_neg_integer()) ::
  map()
```

The create input for `resource`, after creating a record for each required
`belongs_to` in `tenant` as `actor`.

# `sample`

```elixir
@spec sample(map(), module()) :: map()
```

The sample attributes for `resource` in `samples`: the map, or what its function returns.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
