Seeding
Testereiro supports two seeding paths.
engine.Seed(...) inserts struct values into SQL tables.
| |
This requires a configured SQL database on the engine.
The table is the snake_case type name made plural: Game seeds games, JobCategory seeds
job_categories (a consonant before the final y takes ies), ApiKey seeds api_keys, and a
name ending in x is left as it is, so JobOutbox seeds job_outbox.
A type whose table does not follow that rule names it with a TableName() string method:
| |
A type you cannot add a method to, such as a generated row, gets one through a defined type over
it: type UsageMonthly gen.UsageMonthly keeps the fields and their db tags.
engine.SeedWithProvider(...) executes one or more SeedProvider values.
| |
SeedProvider is any type implementing:
| |
Mongo examples use providers/mongotestage/pkg/mongoseeder to seed collections.
WithBeforeEngineSeed runs before both:
engine.Seed(...)engine.SeedWithProvider(...)