-
Notifications
You must be signed in to change notification settings - Fork 7
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 config options: queue name, BQ timeout, BQ retries #1
Conversation
lib/dfe/analytics/testing/helpers.rb
Outdated
@@ -36,6 +36,17 @@ def stub_analytics_event_submission | |||
stub_request(:post, /bigquery.googleapis.com/) | |||
.to_return(status: 200, body: '{}', headers: { 'Content-Type' => 'application/json' }) | |||
end | |||
|
|||
def with_analytics_config(options) | |||
old_config = DfE::Analytics.config |
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.
DfE::Analytics.config
and old_config
are the same thing (Ruby is pass by reference 😛 , see pry
session below), so you should probably dup config
:
old_config = DfE::Analytics.config | |
old_config = DfE::Analytics.config.dup |
Pry session:
From: /Users/misaka/Code/DfE/dfe-analytics/lib/dfe/analytics/testing/helpers.rb:48 DfE::Analytics::Testing::Helpers#with_analytics_config:
40: def with_analytics_config(options)
41: old_config = DfE::Analytics.config
42: DfE::Analytics.configure do |config|
43: options.each { |option, value| config[option] = value }
44: end
45:
46: yield
47: ensure
=> 48: binding.pry
49: DfE::Analytics.instance_variable_set(:@config, old_config)
50: end
[1] pry(#<RSpec::ExampleGroups::AnalyticsFlow::WhenAQueueIsSpecified>)> options
=> {:queue=>:my_custom_queue}
[2] pry(#<RSpec::ExampleGroups::AnalyticsFlow::WhenAQueueIsSpecified>)> DfE::Analytics.config[:queue]
=> :my_custom_queue
[3] pry(#<RSpec::ExampleGroups::AnalyticsFlow::WhenAQueueIsSpecified>)> old_config[:queue]
=> :my_custom_queue
Proof dup
works:
[41] pry(#<RSpec::ExampleGroups::AnalyticsFlow::WhenAQueueIsSpecified>)> old_config = DfE::Analytics.config.dup
=> #<struct
...
queue=:default,
...>
[42] pry(#<RSpec::ExampleGroups::AnalyticsFlow::WhenAQueueIsSpecified>)> DfE::Analytics.config[:queue] = :my_custom_queue
=> :my_custom_queue
[43] pry(#<RSpec::ExampleGroups::AnalyticsFlow::WhenAQueueIsSpecified>)> old_config[:queue]
=> :default
[44] pry(#<RSpec::ExampleGroups::AnalyticsFlow::WhenAQueueIsSpecified>)> DfE::Analytics.config[:queue]
=> :my_custom_queue
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.
Very good point, thank you!
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.
lesson: test your tests
815f22c
to
d58f3d1
Compare
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.
\o/
Clients can now configure the ActiveJob queue name, plus the BigQuery timeout and retry count options.