Skip to content

Commit

Permalink
feat(disable-hiseq-submission-template): moves logging to Rails logge…
Browse files Browse the repository at this point in the history
…r and updates tests
  • Loading branch information
BenTopping committed Jul 29, 2024
1 parent dd48091 commit 898c753
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/tasks/support/disable_hiseq_submission_templates.rake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace :support do
templates_changed += 1
end
end
puts "Disabled #{templates_changed} HiSeq submission templates."
Rails.logger.info("Disabled #{templates_changed} HiSeq submission templates.")
end

desc 'Enable the HiSeq submission templates'
Expand All @@ -34,6 +34,6 @@ namespace :support do
templates_changed += 1
end
end
puts "Enabled #{templates_changed} HiSeq submission templates."
Rails.logger.info("Enabled #{templates_changed} HiSeq submission templates.")
end
end
16 changes: 10 additions & 6 deletions spec/tasks/support/disable_hiseq_submission_templates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
Rails.application.load_tasks if Rake::Task.tasks.empty?

describe 'support:disable_hiseq_submission_templates', type: :task do
let(:task_invoke) { Rake::Task[self.class.top_level_description].invoke }

context 'when the disable_hiseq_submission_templates task is invoked' do
it 'updates all hiseq submissions to have a superceded_by_id of -2' do

Check failure on line 10 in spec/tasks/support/disable_hiseq_submission_templates_spec.rb

View workflow job for this annotation

GitHub Actions / rspec_tests (3, 2)

support:disable_hiseq_submission_templates when the disable_hiseq_submission_templates task is invoked updates all hiseq submissions to have a superceded_by_id of -2 Failure/Error: expect(Rails.logger).to have_received(:info).with('Disabled 10 HiSeq submission templates.') (#<Logger:0x00007fef1efddbc0 @Level=0, @progname=nil, @default_formatter=#<Logger::Formatter:0x00007fef1fc793c0 @datetime_format=nil>, @Formatter=#<Logger::Formatter:0x00007fef1fc78268 @datetime_format=nil>, @logdev=#<Logger::LogDevice:0x00007fef1efddb70 @shift_period_suffix="%Y%m%d", @shift_size=10485760, @shift_age=5, @filename=#<Pathname:/home/runner/work/sequencescape/sequencescape/log/test.log>, @dev=#<File:/home/runner/work/sequencescape/sequencescape/log/test.log>, @binmode=false, @mon_data=#<Monitor:0x00007fef1fc78ad8>, @mon_data_owner_object_id=7220>, @level_override={}>).info("Disabled 10 HiSeq submission templates.") expected: 1 time with arguments: ("Disabled 10 HiSeq submission templates.") received: 5 times with arguments: ("Disabled 10 HiSeq submission templates.")

Check failure on line 10 in spec/tasks/support/disable_hiseq_submission_templates_spec.rb

View workflow job for this annotation

GitHub Actions / rspec_tests (3, 2)

support:disable_hiseq_submission_templates when the disable_hiseq_submission_templates task is invoked updates all hiseq submissions to have a superceded_by_id of -2 Failure/Error: expect(Rails.logger).to have_received(:info).with('Disabled 10 HiSeq submission templates.') (#<Logger:0x00007fc7d90543a0 @Level=0, @progname=nil, @default_formatter=#<Logger::Formatter:0x00007fc7d9b76af8 @datetime_format=nil>, @Formatter=#<Logger::Formatter:0x00007fc7d9b760a8 @datetime_format=nil>, @logdev=#<Logger::LogDevice:0x00007fc7d9054350 @shift_period_suffix="%Y%m%d", @shift_size=10485760, @shift_age=5, @filename=#<Pathname:/home/runner/work/sequencescape/sequencescape/log/test.log>, @dev=#<File:/home/runner/work/sequencescape/sequencescape/log/test.log>, @binmode=false, @mon_data=#<Monitor:0x00007fc7d9b76620>, @mon_data_owner_object_id=7220>, @level_override={}>).info("Disabled 10 HiSeq submission templates.") expected: 1 time with arguments: ("Disabled 10 HiSeq submission templates.") received: 5 times with arguments: ("Disabled 10 HiSeq submission templates.")
# Create unused submission templates
Expand All @@ -19,7 +17,11 @@
create(:submission_template, name: "Some other hiseq #{i}")
end

expect { task_invoke }.to output("Disabled 10 HiSeq submission templates.\n").to_stdout
allow(Rails.logger).to receive(:info)

Rake::Task['support:disable_hiseq_submission_templates'].invoke

expect(Rails.logger).to have_received(:info).with('Disabled 10 HiSeq submission templates.')
# Expect all hiseq submissions to have a superceded_by_id of -2
expect(SubmissionTemplate.where('name LIKE ?', '%hiseq%').all? { |st| st.superceded_by_id == -2 }).to be true
# Expect all other submissions to have a superceded_by_id of -1
Expand All @@ -38,9 +40,11 @@
create(:submission_template, name: "Some other hiseq #{i}", superceded_by_id: -2)
end

expect { Rake::Task['support:enable_hiseq_submission_templates'].invoke }.to output(
"Enabled 10 HiSeq submission templates.\n"
).to_stdout
allow(Rails.logger).to receive(:info)

Rake::Task['support:enable_hiseq_submission_templates'].invoke

expect(Rails.logger).to have_received(:info).with('Enabled 10 HiSeq submission templates.')
# Expect all hiseq submissions to have a superceded_by_id of -1
expect(SubmissionTemplate.where('name LIKE ?', '%hiseq%').all? { |st| st.superceded_by_id == -1 }).to be true
end
Expand Down

0 comments on commit 898c753

Please sign in to comment.