-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
Validate options in dev mode #772
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,6 +160,12 @@ defmodule Sentry.Client do | |
end | ||
end | ||
|
||
@spec validate_and_ignore(keyword()) :: :ignored | ||
def validate_and_ignore(opts) when is_list(opts) do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can also re-use this function above where we call |
||
_opts = NimbleOptions.validate!(opts, @send_event_opts_schema) | ||
:ignored | ||
end | ||
|
||
defp sample_event(sample_rate) do | ||
cond do | ||
sample_rate == 1 -> :ok | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -119,6 +119,16 @@ defmodule SentryTest do | |||||||||||||
assert logged_count == 2 | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
test "raises error with validate_and_ignore/1 in dev mode if opts passed are invalid " do | ||||||||||||||
put_test_config(dsn: nil, test_mode: false) | ||||||||||||||
|
||||||||||||||
assert_raise(NimbleOptions.ValidationError, fn -> | ||||||||||||||
Sentry.Client.validate_and_ignore(client: [bad_key: :nada]) | ||||||||||||||
end) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit:
Suggested change
|
||||||||||||||
|
||||||||||||||
assert :ignored == Sentry.Client.validate_and_ignore(client: :hackney) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit, but matches other tests:
Suggested change
|
||||||||||||||
end | ||||||||||||||
|
||||||||||||||
test "does not send events if :dsn is not configured or nil (if not in test mode)" do | ||||||||||||||
put_test_config(dsn: nil, test_mode: false) | ||||||||||||||
event = Sentry.Event.transform_exception(%RuntimeError{message: "oops"}, []) | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is gonna make it harder to track the return value–I have to jump to another module. Maybe we can do
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good idea!