-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[breaking change] mapping rules will be replaced instead of adding mi…
…ssing ones
- Loading branch information
Showing
10 changed files
with
75 additions
and
3 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
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
18 changes: 18 additions & 0 deletions
18
lib/3scale_toolbox/commands/backend_command/copy_command/delete_mapping_rules_task.rb
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module ThreeScaleToolbox | ||
module Commands | ||
module BackendCommand | ||
module CopyCommand | ||
class DeleteMappingRulesTask | ||
include Task | ||
|
||
# entrypoint | ||
def run | ||
return unless delete_mapping_rules | ||
|
||
target_backend.mapping_rules.each(&:delete) | ||
end | ||
end | ||
end | ||
end | ||
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
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
37 changes: 37 additions & 0 deletions
37
spec/unit/commands/backend_command/copy_command/delete_mapping_rules_task_spec.rb
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
RSpec.describe ThreeScaleToolbox::Commands::BackendCommand::CopyCommand::DeleteMappingRulesTask do | ||
let(:target) { instance_double('ThreeScaleToolbox::Entities::Service', 'target') } | ||
let(:base_context) { { target_backend: target, logger: Logger.new('/dev/null') } } | ||
let(:task_context) { base_context } | ||
subject { described_class.new(task_context) } | ||
|
||
context '#run' do | ||
context 'delete_mapping_rules flag false' do | ||
let(:task_context) { base_context.merge(delete_mapping_rules: false) } | ||
it 'no op' do | ||
# Run | ||
subject.call | ||
end | ||
end | ||
|
||
context 'several mapping rules available' do | ||
let(:task_context) { base_context.merge(delete_mapping_rules: true) } | ||
let(:n_rules) { 10 } | ||
let(:target_mapping_rules) do | ||
Array.new(n_rules) do |_| | ||
instance_double('ThreeScaleToolbox::Entities::MappingRule') | ||
end | ||
end | ||
|
||
it 'it calls delete_mapping_rule method on each rule' do | ||
expect(target).to receive(:mapping_rules).and_return(target_mapping_rules) | ||
expect(target_mapping_rules.size).to be > 0 | ||
target_mapping_rules.each do |mapping_rule| | ||
expect(mapping_rule).to receive(:delete) | ||
end | ||
|
||
# Run | ||
subject.call | ||
end | ||
end | ||
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