Cruz

Cruz

Doctests not executing after been wrapped by a plug_cowboy app

Hi,

I recently wrapped an Elixir app with a plug_cowboy endpoint. Everything is working fine, but when I do:

mix test

just the tests that I have defined in the plug_cowboy app are executed. I don’t get any errors, but the doctests that I have in the “pure” Elixir app are ignored.

It’s not a big deal as they still show in the documentation, but ideally I don’t want to repeat them at the plug_cowboy layer. Is there an easy way to get them executed by mix?

Just in case, my directory structure looks like this now:

cowboy_app_dir
  lib
    application.ex
    endpoint.ex
  pure_elixir_app_dir
    pure_elixir_app_logic.ex - Doctests here are being ignored by mix
  cowboy_app_test_dir
    cowboy_app_test.exs - All tests here being run by mix

Thanks in advance

Most Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

A single mix.exs file builds a single elixir application. If you want to have multiple applications within a single project you can use a mix umbrella project. Can you show your mix.exs file?

axelson

axelson

Scenic Core Team

When I do development like that I usually just run each of the apps tests individually. You could also write a small bash script that would run each test suite (or a makefile)

Cruz

Cruz

Having two distinct applications a la PragDave has its advantages, but for the moment, I think I like the idea of the umbrella app. This is my current mix.exs

defmodule Estimator.MixProject do
  use Mix.Project

  def project do
    [
      app: :estimator,
      version: "0.1.0",
      elixir: "~> 1.8",
      start_permanent: Mix.env() == :prod,
      deps: deps()
    ]
  end

  # Run "mix help compile.app" to learn about applications.
  def application do
    [
      extra_applications: [:logger],
      mod: {Estimator.Application, []}
    ]
  end

  # Run "mix help deps" to learn about dependencies.
  defp deps do
    [
      {:plug_cowboy, "~> 2.0"},
      {:jason, "~> 1.1"},
      {:csv, "~> 2.3"},
      {:ex_doc, "~> 0.19", only: :dev, runtime: false}
    ]
  end
end

Thank you

Where Next?

Popular in Questions Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
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
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New

Other popular topics Top

dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement