-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #427 from Shopify/use-rails-logger
Use the Rails application logger
- Loading branch information
Showing
16 changed files
with
125 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ GIT | |
PATH | ||
remote: . | ||
specs: | ||
job-iteration (1.4.0) | ||
job-iteration (1.4.1) | ||
activejob (>= 5.2) | ||
|
||
GEM | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module JobIteration | ||
VERSION = "1.4.0" | ||
VERSION = "1.4.1" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,55 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class IntegrationsTest < IterationUnitTest | ||
class IterationJob < ActiveJob::Base | ||
include JobIteration::Iteration | ||
|
||
def build_enumerator(cursor:) | ||
enumerator_builder.build_once_enumerator(cursor: cursor) | ||
end | ||
|
||
def each_iteration(*) | ||
require "open3" | ||
|
||
class IntegrationsTest < ActiveSupport::TestCase | ||
test "will prevent loading two integrations" do | ||
with_env("ITERATION_DISABLE_AUTOCONFIGURE", nil) do | ||
rubby = <<~RUBBY | ||
require 'bundler/setup' | ||
require 'job-iteration' | ||
RUBBY | ||
_stdout, stderr, status = run_ruby(rubby) | ||
|
||
assert_equal false, status.success? | ||
assert_match(/resque integration has already been loaded, but sidekiq is also available/, stderr) | ||
end | ||
end | ||
|
||
class ResqueJob < IterationJob | ||
self.queue_adapter = :resque | ||
end | ||
|
||
class SidekiqJob < IterationJob | ||
self.queue_adapter = :sidekiq | ||
end | ||
|
||
test "loads multiple integrations" do | ||
resque_job = ResqueJob.new.serialize | ||
ActiveJob::Base.execute(resque_job) | ||
|
||
sidekiq_job = SidekiqJob.new.serialize | ||
ActiveJob::Base.execute(sidekiq_job) | ||
test "successfully loads one (resque) integration" do | ||
with_env("ITERATION_DISABLE_AUTOCONFIGURE", nil) do | ||
rubby = <<~RUBBY | ||
require 'bundler/setup' | ||
# Remove sidekiq, only resque will be left | ||
$LOAD_PATH.delete_if { |p| p =~ /sidekiq/ } | ||
require 'job-iteration' | ||
RUBBY | ||
_stdout, _stderr, status = run_ruby(rubby) | ||
|
||
assert_equal true, status.success? | ||
end | ||
end | ||
|
||
test ".register accepts an object does implementing #call" do | ||
JobIteration::Integrations.register(:registration_test, -> { true }) | ||
private | ||
|
||
assert(JobIteration::Integrations.registered_integrations[:registration_test].call) | ||
end | ||
def run_ruby(body) | ||
stdout, stderr, status = nil | ||
Tempfile.open do |f| | ||
f.write(body) | ||
f.close | ||
|
||
test ".register raises when the callable object does not implement #call" do | ||
error = assert_raises(ArgumentError) do | ||
JobIteration::Integrations.register("foo", "bar") | ||
command = "ruby #{f.path}" | ||
stdout, stderr, status = Open3.capture3(command) | ||
end | ||
assert_equal("Interruption adapter must respond to #call", error.message) | ||
[stdout, stderr, status] | ||
end | ||
|
||
test "raises for unknown Active Job queue adapter names" do | ||
error = assert_raises(JobIteration::Integrations::LoadError) do | ||
JobIteration::Integrations.load("unknown") | ||
end | ||
assert_equal("Could not find integration for 'unknown'", error.message) | ||
def with_env(variable, value) | ||
original = ENV[variable] | ||
ENV[variable] = value | ||
yield | ||
ensure | ||
ENV[variable] = original | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.