elixir

Elixir Telegram Bot

published on
The quest was to develop a telegram bot over 24hrs, during an office hackathon event. I started out consulting documentation. Bot interaction was implemented as a GenServer named ConversationTree defmodule TelegramService.ConversationTree do use GenServer def start_link(name, conversation \\ %{message: [], response: [], tickets: []}) do {:ok, _} = GenServer.start_link(__MODULE__, conversation, name: name) name end def lookup(name) do GenServer.whereis(name) end def kill(name) do GenServer.stop(name) end def write_message(name, message = %{}) do GenServer. Read More...

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.