Skip to content
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

Clean up server integration tests #474

Merged
merged 1 commit into from
Jan 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions spec/integration/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,44 @@

RSpec.describe 'Server modes', skip_if_java: true do
context 'when development async' do
it 'successfully starts the server' do
it 'successfully runs in the server' do
env = {
"RAILS_ENV" => "development",
"GOOD_JOB_EXECUTION_MODE" => "async",
"GOOD_JOB_ENABLE_CRON" => "true",
}

ShellOut.command('bundle exec rails s', env: env) do |shell|
wait_until(max: 30) do
expect(shell.output).to include(/Listening on/)
# In development, GoodJob starts up before Puma redirects logs to stdout
expect(shell.output).to include(/Enqueued ExampleJob/)
end
end
end
end

context 'when production async' do
it 'successfully runs' do
it 'successfully runs in the server' do
env = {
"RAILS_ENV" => "production",
"GOOD_JOB_EXECUTION_MODE" => "async",
"GOOD_JOB_ENABLE_CRON" => "true",
}
ShellOut.command('bundle exec rails s', env: env) do |shell|
wait_until(max: 30) do
expect(shell.output).to include(/Listening on/)
expect(shell.output).to include(/GoodJob started scheduler/)
expect(shell.output).to include(/GoodJob started cron/)
end
end
end
end

context 'when production async_server' do
let(:env) do
{
it 'does not start GoodJob when running other commands' do
env = {
"RAILS_ENV" => "production",
"GOOD_JOB_EXECUTION_MODE" => "async_server",
"GOOD_JOB_EXECUTION_MODE" => "async",
}
end

it 'starts GoodJob when running web server' do
ShellOut.command('bundle exec rails s', env: env) do |shell|
wait_until(max: 30) do
expect(shell.output).to include(/GoodJob started scheduler/)
end
end
end

it 'does not start GoodJob when running other commands' do
ShellOut.command('bundle exec rails db:version', env: env) do |shell|
wait_until(max: 30) do
expect(shell.output).to include(/Current version/)
Expand Down