Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests to the error handling when using multiple endpoints #545

Merged
merged 4 commits into from
May 20, 2021

Conversation

chaodhib
Copy link
Contributor

This PR is a minor follow up to #544. I thought it would be better to add those 2 tests to the error handling

@josevalim
Copy link
Member

I pushed a small change to the error message, can you please rebase and update your tests? Thanks!

@chaodhib
Copy link
Contributor Author

Sure, done


assert_start_and_killed(opts ++ context[:options])
end) =~
~r'\*\* \(Postgrex\.Error\) failed to establish connection to multiple endpoints\:\n\n \* doesntexist\:5432\: \(DBConnection\.ConnectionError\) tcp connect \(doesntexist\:5432\)\: non\-existing domain \- \:nxdomain\n \* localhost\:5555\: \(DBConnection\.ConnectionError\) tcp connect \(localhost\:5555\)\: connection refused \- \:econnrefused'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think those need to be regexes, as using a string will also be a submatch. Can we use strings instead? They should be easier to read. :) Thanks!

Copy link
Contributor Author

@chaodhib chaodhib May 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. done :)

@chaodhib
Copy link
Contributor Author

Here is the current output:

** (Postgrex.Error) failed to establish connection to multiple endpoints:

  * doesntexist:5432: (DBConnection.ConnectionError) tcp connect (doesntexist:5432): non-existing domain - :nxdomain
  * localhost:5555: (DBConnection.ConnectionError) tcp connect (localhost:5555): connection refused - :econnrefused
    (db_connection 2.1.0) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.11) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

Is the double newline character after "multiple endpoints:" intended? Wouldn't one newline be enough?

@josevalim
Copy link
Member

@chaodhib it is intentional, most Elixir exceptions use that standard. :)

@chaodhib
Copy link
Contributor Author

@josevalim good to know. thank you :)

@josevalim josevalim merged commit 6cc68d8 into elixir-ecto:master May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants