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.

https://github.com/fbeline/copeiro

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.

Where Next?

Popular in Announcing Top

OvermindDL1
I created a new library (rather I pulled out a couple files from my big project), it manages an operating system PID file for the BEAM. ...
New
tmbb
I’ve published the first version of my Makeup library. It’s a syntax highlighter for Elixir in the spirit of Pygments, Currently it highl...
New
mischov
import Meeseeks.CSS html = HTTPoison.get!("https://news.ycombinator.com/").body for story <- Meeseeks.all(html, css("tr.athing")) do...
New
Crowdhailer
I have been updating a library that allows you to pipe between functions that use the erlang result tuple convention. Assuming you have ...
New
tmbb
I’ve been working on two packages (not on hex.pm yet) to build admin interfaces for phoenix apps: bureaucrat - which contains a bunch ...
New
cjen07
parameterized pipe in elixir: |n> edit: negative index in |n> and mixed usage with |> are supported example: use ParamPipe ...
New
josevalim
Hello everyone, We have just released NimbleCSV which is a small and fast CSV parsing library for Elixir. It allows developers to define...
New
OvermindDL1
Been making an MLElixir thing (not released yet…) for fun in spare time in the past day. I’m just trying to see how much I can get an ML...
132 13966 106
New
zoltanszogyenyi
Hey everyone :waving_hand: Excited to join this forum - I am one of the founders and current project maintainers of a popular and open-s...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New

Other popular topics Top

Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43622 214
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
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
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New

We're in Beta

About us Mission Statement