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 6 to 1

fireproofsocks

fireproofsocks OP

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

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

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.

dimitarvp

dimitarvp

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!

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.

— 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
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
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
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
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
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
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
aseigo
ICal is a library for interacting with iCalendar data. It parses iCalendars into typed Elixir structs via ICal.from_ics, and can prepare ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews