From Ruby to Elixir: test send_sms_message/1 missing configuration in test.exs

Page 178 describing the test send_sms_message/1. We are missing to mention that the test.exs should import the dev secrets

import_config "./dev.secret.exs"

If not we get into the error:

test/phone_app/conversations/conversations_test.exs:8
     ** (KeyError) key :number not found in: []

Which comes from not getting any value on (lib/phone_app/conversations/conversations.ex)

  def your_number do
    twilio_config = Application.get_env(:phone_app, :twilio, [])
    Keyword.fetch!(twilio_config, :number)
  end

I believe this is on page 149, but it would be very easy to miss.

edit: see next comment, this is referring to dev and not test.

Ah apologies, I see that is dev and not test.

On page 181, we setup the test.exs file with a mock configuration. This prevents the leaking of credentials between dev and test.

I do not recommend importing real secrets into an environment that it’s not intended for.