fireproofsocks

fireproofsocks

I’m a bit confused as to how Ecto works with seeded data when it is conducting its tests. What EXACTLY is the flow when you commence a test run (whether it be all of them via “mix test”, or only a specific file, or a specific test by specifying a line number)? Does the testing database get seeded in this process?

For example, I have some data (e.g. a list of countries) that should be the same in all environments. Do I need to explicitly seed that in the testing database? I have other data that I COULD seed ONLY in the test database just to help write thorough integration tests. How should that be best accomplished?

Thanks for any guidance!

Showing Posts 1 to 6

LostKobrakai

LostKobrakai

mix test won’t seed your database, because nothing will cleanup the data which was inserted outside of the sandbox transactions of single tests. Also having those countries seeded would mean they are the same to all tests, which imho can be as annoying as any other global state in your system. I’d rather opt for inserting those countries via a Factory on demand, so you can control on a per test basis which countries are in the database.

fireproofsocks

fireproofsocks OP

How do you make a factory that would seed the testing database? If I run the seed operation using mix, it will by default get added to my dev database. Thanks!

dimitarvp

dimitarvp

fireproofsocks

fireproofsocks OP

Interesting… but that generates random data. I’m really needing to seed specific data for some pretty specific tests… especially when some of the end-to-end tests in our architecture are further downstream.

LostKobrakai

LostKobrakai

A factory is about making it easy to inserts some data into the database. If it’s random or not is more about what you need. In a simple case it could just be a module, which you wrote, that does add some data to the db.

fireproofsocks

fireproofsocks OP

Thank you, this is helpful – I need some time to digest it.

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews