fbeline

fbeline

Copeiro - testing library

After working with Elixir for a few months, I’ve noticed extra efforts by me and my colleagues when writing tests involving lists.
Usually those issues was related to ordering. Sometimes even producing flaky behavior.

With that in mind, I wrote a small library that provides a way to assert lists in an idiomatic way and does not make me feel “weird” about it.

Please, feel free to share your thoughts around the subject :raised_hands:

Most Liked

eksperimental

eksperimental

Just one comment. You don’ t need to require a module if you are importing it.

al2o3cr

al2o3cr

I’ve seen this, but it’s generally been a symptom of code that was relying on Postgres returning rows in insertion order in tests when not using an order_by clause.

IMO the flakiness there indicates a bug, so hiding it by making comparisons order-insensitive wouldn’t be ideal.

fbeline

fbeline

I’ve seen this, but it’s generally been a symptom of code that was relying on Postgres returning rows in insertion order in tests when not using an order_by clause.

Yes, that is exactly the point. In several tests the order does not matter and the insertion order is not the expected one for some runs.

IMO the flakiness there indicates a bug, so hiding it by making comparisons order-insensitive wouldn’t be ideal.

It’s not necessarily a bug in your code. In my experience it’s usually related to a missing “order_by” (in test) as you said.

Also, you should not use a function that checks if it’s a “subset” or ignore order if order is something important to your business rules.

eksperimental

eksperimental

Personally I wouldn’t use in since it is an operator that behaves in a different way. I would use has and has not, but you will have to flip the arguments. Or name it something else.

Where Next?

Popular in Libraries Top

mhanberg
I just released the first version of Temple: an HTML DSL for Elixir and Phoenix! You can read this blog post or the docs for more info...
New
zoltanszogyenyi
Hey everyone :wave: Excited to join this forum - I am one of the founders and current project maintainers of a popular and open-source U...
New
treble37
Just looking for a little feedback on a tiny helper library I built - Sometimes I find the need to convert maps with atom keys to maps...
New
michalmuskala
Another small library today. PersistentEts Hex: persistent_ets | Hex GitHub: GitHub - michalmuskala/persistent_ets Ets table backed by...
New
benlime
I created a new library GitHub - benvp/ex_cva: Class Variance Authority for Elixir which aims to make it very easy to define different va...
New
ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
wmnnd
Hi there, for my project DBLSQD, I needed a file storage solution that is a bit more flexible than Arc. Because I thought others might f...
New
ericlathrop
I built a silly site for Halloween that uses Phoenix Channels on the backend, and React on the frontend. I had many problems integrating ...
New
gabrielpoca
Hello everyone! I want to share with you something that I’m really proud of: https://stillstatic.io/ Still is a static site builder for...
New
Azolo
Hey everyone, I just released WebSockex which is a Elixir WebSocket client. WebSockex strives to work as a OTP special process, be RFC6...
New

Other popular topics Top

axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New

Sub Categories:

We're in Beta

About us Mission Statement