Testing a phoenix controller

published on
The snippet below is a phoenix framework controller test defmodule PaymentServiceWeb.Controllers.PaymentTest do use ExUnit.Case, async: false use Plug.Test alias PaymentServiceWeb.Router @tag endpoint: true test "service health check" do conn = conn(:get, "/api") response = Router.call(conn, @opts) assert %Plug.Conn{resp_body: body} = response end end Explanation The test above is going to test an api endpoint, and the simple assertion is just to ensure that a %Plug.Conn struct is received as the response. Read More...

List of amazing elixir resource

published on
Here is an amazing list of handy libraries to use for elixir development. I have personally used the rsa_ex library which made the list in one of my projects. This can come handy in your next project. Share.

Recursion in elixir

published on
I am new to elixir, and I find this interesting at the time of writing, I am coming from NodeJs :) The major ingredients of recursion are: An exercise to perform repeatedly, A condition to break off the repeated exercise Lets say we want to write a function that will return building identifiers where restaurants have not yet closed. The first argument is the current hour as integer, the second argument is the current minute as integer, the third argument is the list of restaurants containing; the name of the canteen, building identifier, closing hour, closing minute. Read More...