Testing the Phoenix controllers without rebinding the conn

Maybe, for readability purposes, you prefer to avoid variable rebinding. For example, take this generated test code from mix phx.gen.auth task: test "renders log in page", %{conn: conn} do conn = get(conn, Routes.user_session_path(conn, :new)) response = html_response(conn, 200) assert response =~ "Log in" assert response =~ "Register</a>" assert response =~ "Forgot password?</a>" end It’s completely ok. But, you can prefer something like this: test "renders log in page", %{conn: conn} do response = conn |> get(Routes....

mayo 11, 2022 · Me

How to build a flexible API client in Elixir

Normally, to talk with an external API we will search some library to do the work for us. Sometimes, this search is infructuous for some of the next reasons: Exist one or more libraries but are unmaintained. There is no library at all. Existing libraries do not fit our requirements. At this point, you could take the following paths. 1 Build a service module in your app Maybe you just need to consume some endpoints and already use some HTTP client like Tesla....

enero 19, 2022 · Me

Procesando archivos de forma asíncrona con Elixir

Escenario A veces, no todo es un escenario perfecto y puede que para alimentar de información tu aplicación necesitas; no conectarte a una API, si no subir archivos CSV’s. Si es el caso, no quieres que quien sea responsable de esta tarea tenga que subir de 100 en 100 registros por que si sube un archivo con 101, el servidor tarda demasiado en responder, el navegador muestra un error de timeout y la carga se interrumpe....

julio 14, 2020 · Me