RicoTrevisan

RicoTrevisan

How to test a Burrito-wrapped app?

I was having a hard time running tests and wrapping my tiny app with Burrito so I came up with this strategy, but I wasn’t sure if this is the best way to go about it.

Is there a simpler way to do it?

# config.exs
import Config

config :pled, compile_env: Mix.env()
# application.ex
defmodule Pled.Application do
  use Application

  alias Pled.CLI

  @impl true
  def start(_type, _args) do
    env = Application.get_env(:pled, :compile_env)

    if env == :test do
      children = []
      opts = [strategy: :one_for_one, name: Pled.Supervisor]
      Supervisor.start_link(children, opts)
    else
      Burrito.Util.Args.argv()
      |> CLI.parse_args()
      |> CLI.handle_command()

      System.halt(0)
    end
  end
end

Most Liked

Schultzer

Schultzer

Looks solid to me.

LostKobrakai

LostKobrakai

:peer iirc allows testing beam applications even if e.g. wrapped in a docker image. I‘d expect that could also be done to burrito binaries with a bit of setup.

Where Next?

Popular in Questions Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
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
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
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
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130286 1222
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36654 110
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
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
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44532 311
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement