-
Notifications
You must be signed in to change notification settings - Fork 53
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
Ideas for new features #39
Comments
support for testing? I am not able to test anything where a worker is being invoked which includes |
@salmanasiddiqui Could you please specify what exactly does not work for you? This is an exerpt from one of my one tests: let(:container) do
jid = described_class.perform_async(client_id, user_id, path) # this is required for SidekiqStatus to propertly initialize container
container = Workers::AsyncJobWorkerMixin::Container.load(jid)
end
let(:payload) { container.payload.fetch(InternalApi::Users::AsyncJobsController::PAYLOAD_FOR_CLIENT).symbolize_keys }
around do |example|
Sidekiq::Testing.inline! do
example.call
end
end
it "works" do
stub_entity_assignments_call_for(user_id).and_return(build_entity_assignments_response([item1, item2].map(&:catalog_node).map(&:id)))
expect(payload).to include(status: 'success')
end
end I am sorry it has a lot of unrelated (client project-specific test code) but it shows the idea:
Or do you mean some other use case for tests? |
There is this action in controller which is supposed to return status of job
RESPONSE:
So I wanted to write two tests for this action
For first test:
For second test:
no I already have included Sidekiq Version: 3.4.0 |
@salmanasiddiqui Looks like you just need to simply mock the SidekiqStatus::Container and the expect(SidekiqStatus::Container).to receive(:load).with(jid).and_return(SidekiqStatus::Container.new(jid, {
status: __here goes the desired status__,
total: integer,
completed: integer,
})) as you are essentially not testing your Sidekiq::Status job here, but you test the behaviour of your controller depending on the status of the job. So just stub the call. |
and what if I wanted to test my job? 😄 If I could then I would have definitely loved to contribute in terms of PR but right now I lack both the time and knowledge for this 😞 |
Please suggest any ideas of what has to be added to the project.
The text was updated successfully, but these errors were encountered: