You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 1, 2023. It is now read-only.
I'm trying to test some controllers of my application with rspec, one of them use background jobs with sidekiq and sidekiq-status.
I folowed the guide (https://github.com/utgarda/sidekiq-status#testing) to enabling testing for inline mode but when i launch tests Redis::CannotConnectError exceptions is fired.
The worker is launched inside a method of my controller with:
classProductImportWorkerincludeSidekiq::WorkerincludeSidekiq::Status::Worker# enables job status trackingdefperform(file_path,debug=false)logger.info"ProductImportWorker START import from file: #{file_path} ..."# read all import_data hash from file saved in temp directoryunlessFile.exist?(file_path)raise"source file not found"endimport_data=File.open(file_path,"r"){|from_file| Marshal.load(from_file)}moltiplicator=100.0 / import_data&.sizelogger.info"ProductImportWorker START import #{import_data&.size} products..."# set first sidekiq status percentage end messageat0,"Started"ActiveRecord::Base.transactiondoimport_data.each_with_indexdo |product_hash,index|
ifdebugsleep(0.05)else# for each product verify if it exists, then update it, else create a new oneinternal_code=product_hash.dig(:internal_code)existing_product=Product.find_by_internal_code(internal_code.to_s)ifexisting_product# Update existing productexisting_product.update!(product_hash)else# Create a new productProduct.create!(product_hash)endend# percentage of completion overall processperc=((index + 1) * moltiplicator).to_ilogger.info"CREATED product #{index}, completion: #{perc}%"# update sidekiq status percentage end messageatperc,"Waiting ..."endendFile.delete(file_path)ifFile.exist?(file_path)logger.info"ProductImportWorker FINISH"at100,"Finish"endend
if i comment include Sidekiq::Status::Worker with all at commands the worker is executed and test pass so the sidekiq/testing/inline works.
Seems that import require 'sidekiq-status/testing/inline' doesn't work properly, someone has encountered the same problem ?
The text was updated successfully, but these errors were encountered:
I'm trying to test some controllers of my application with rspec, one of them use background jobs with sidekiq and sidekiq-status.
I folowed the guide (https://github.com/utgarda/sidekiq-status#testing) to enabling testing for inline mode but when i launch tests Redis::CannotConnectError exceptions is fired.
The worker is launched inside a method of my controller with:
job_id = ProductImportWorker.perform_async(file_path)
in spec_helper.rb i added the folowing lines:
Folowing the code of my worker class:
if i comment
include Sidekiq::Status::Worker
with allat
commands the worker is executed and test pass so thesidekiq/testing/inline
works.Seems that import
require 'sidekiq-status/testing/inline'
doesn't work properly, someone has encountered the same problem ?The text was updated successfully, but these errors were encountered: