polypush135

polypush135

Trying to use a config setting in place of dependency injection for testing

So I have a context that creates a post, the post also has an uploaded image that gets processed and later uploaded to S3.

https://github.com/PolymorphicProductions/polymorphic.productions/blob/f4daf357e876e28bf5b722cb2d2aa9ac820934d2/lib/polymorphic_productions/social/pix.ex#L54-L83

Note: @processor and @uploader are being set via the config
https://github.com/PolymorphicProductions/polymorphic.productions/blob/f4daf357e876e28bf5b722cb2d2aa9ac820934d2/lib/polymorphic_productions/social/pix.ex#L12-L13

And if you look in my test config you will see
https://github.com/PolymorphicProductions/polymorphic.productions/blob/f4daf357e876e28bf5b722cb2d2aa9ac820934d2/config/test.exs#L31-L34

You can see that both modules are in my test/support/mocks

The issue I’m having is that when I go to run a test for my pix_create in my context I get a UndefinedFunctionError for the Modules I’ve defined.

❯ mix test test/polymorphic_productions/social/social_test.exs:26
Including tags: [line: "26"]
Excluding tags: [:test]



  1) test pics create_pix/1 with valid data creates a pix (PolymorphicProductions.SocialTest)
     test/polymorphic_productions/social/social_test.exs:26
     ** (UndefinedFunctionError) function PolymorphicProductions.Mocks.Processor.scale_image/1 is undefined (module PolymorphicProductions.Mocks.Processor is not available)
     code: assert {:ok, %Pix{} = pix} = Social.create_pix(param)
     stacktrace:
       PolymorphicProductions.Mocks.Processor.scale_image("test/assets/user_avatar.jpg")
       (polymorphic_productions) lib/polymorphic_productions/social/pix.ex:60: PolymorphicProductions.Social.Pix.upload_attachment/1
       (polymorphic_productions) lib/polymorphic_productions/social/pix.ex:30: PolymorphicProductions.Social.Pix.changeset/2
       (polymorphic_productions) lib/polymorphic_productions/social/social.ex:68: PolymorphicProductions.Social.create_pix/1
       test/polymorphic_productions/social/social_test.exs:30: (test)



Finished in 0.1 seconds
16 tests, 1 failure, 15 excluded

What I’m I missing ? why does the modules fail to load? I assume I need to load the module in the config before I reference it. Just not sure if thats right or how I would go about that

Marked As Solved

polypush135

polypush135

A typo was the issue
“Processer”

Where Next?

Popular in Questions Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
mgjohns61585
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
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
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement