Handle CLI failure exit status at the top-level script (#28322)
This commit is contained in:
parent
881e8c113c
commit
0e0a94f483
27 changed files with 150 additions and 320 deletions
|
@ -65,8 +65,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message' do
|
||||
expect { subject }
|
||||
.to output_results('Failure/Error: email')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, %r{Failure/Error: email})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -127,8 +126,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message indicating the role name was not found' do
|
||||
expect { subject }
|
||||
.to output_results('Cannot find user role with that name')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'Cannot find user role with that name')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -191,8 +189,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message indicating the user was not found' do
|
||||
expect { subject }
|
||||
.to output_results('No user with such username')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No user with such username')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -214,8 +211,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message indicating the role was not found' do
|
||||
expect { subject }
|
||||
.to output_results('Cannot find user role with that name')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'Cannot find user role with that name')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -364,8 +360,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message' do
|
||||
expect { subject }
|
||||
.to output_results('Failure/Error: email')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, %r{Failure/Error: email})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -387,16 +382,14 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message indicating that only one should be used' do
|
||||
expect { subject }
|
||||
.to output_results('Use username or --email, not both')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'Use username or --email, not both')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when neither username nor --email are provided' do
|
||||
it 'exits with an error message indicating that no username was provided' do
|
||||
expect { subject }
|
||||
.to output_results('No username provided')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No username provided')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -425,8 +418,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message indicating that no user was found' do
|
||||
expect { subject }
|
||||
.to output_results('No user with such username')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No user with such username')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -458,8 +450,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message indicating that no user was found' do
|
||||
expect { subject }
|
||||
.to output_results('No user with such email')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No user with such email')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -511,8 +502,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message indicating that the number must be positive' do
|
||||
expect { subject }
|
||||
.to output_results('Number must be positive')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'Number must be positive')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -545,8 +535,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message indicating that no such account was found' do
|
||||
expect { subject }
|
||||
.to output_results('No such account')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No such account')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -560,8 +549,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message indicating that no account with the given username was found' do
|
||||
expect { subject }
|
||||
.to output_results('No such account')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No such account')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -596,8 +584,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message indicating that no account with the given username was found' do
|
||||
expect { subject }
|
||||
.to output_results('No such account')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No such account')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -634,8 +621,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message indicating that there is no such account' do
|
||||
expect { subject }
|
||||
.to output_results('No user with such username')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No user with such username')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -795,8 +781,7 @@ describe Mastodon::CLI::Accounts do
|
|||
allow(Account).to receive(:find_remote).with(account_example_com_b.username, account_example_com_b.domain).and_return(nil)
|
||||
|
||||
expect { subject }
|
||||
.to output_results('No such account')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No such account')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -892,8 +877,7 @@ describe Mastodon::CLI::Accounts do
|
|||
context 'when neither a list of accts nor options are provided' do
|
||||
it 'exits with an error message' do
|
||||
expect { subject }
|
||||
.to output_results('No account(s) given')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No account(s) given')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -904,8 +888,7 @@ describe Mastodon::CLI::Accounts do
|
|||
context 'when neither username nor --all option are given' do
|
||||
it 'exits with an error message' do
|
||||
expect { subject }
|
||||
.to output_results('No account(s) given')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No account(s) given')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -940,8 +923,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message when the specified username is not found' do
|
||||
expect { subject }
|
||||
.to output_results('No such account')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No such account')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -980,8 +962,7 @@ describe Mastodon::CLI::Accounts do
|
|||
shared_examples 'an account not found' do |acct|
|
||||
it 'exits with an error message indicating that there is no such account' do
|
||||
expect { subject }
|
||||
.to output_results("No such account (#{acct})")
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, "No such account (#{acct})")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1031,8 +1012,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message indicating that the accounts do not have the same pub key' do
|
||||
expect { subject }
|
||||
.to output_results("Accounts don't have the same public key, might not be duplicates!\nOverride with --force")
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, "Accounts don't have the same public key, might not be duplicates!\nOverride with --force\n")
|
||||
end
|
||||
|
||||
context 'with --force option' do
|
||||
|
@ -1200,8 +1180,7 @@ describe Mastodon::CLI::Accounts do
|
|||
context 'when no option is given' do
|
||||
it 'exits with an error message indicating that at least one option is required' do
|
||||
expect { subject }
|
||||
.to output_results('Please specify either --follows or --followers, or both')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'Please specify either --follows or --followers, or both')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1211,8 +1190,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message indicating that there is no such account' do
|
||||
expect { subject }
|
||||
.to output_results('No such account')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No such account')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1368,16 +1346,14 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message indicating that using both options is not possible' do
|
||||
expect { subject }
|
||||
.to output_results('Use --replay or --target, not both')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'Use --replay or --target, not both')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when no option is given' do
|
||||
it 'exits with an error message indicating that at least one option must be used' do
|
||||
expect { subject }
|
||||
.to output_results('Use either --replay or --target')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'Use either --replay or --target')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1387,8 +1363,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message indicating that there is no such account' do
|
||||
expect { subject }
|
||||
.to output_results("No such account: #{arguments.first}")
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, "No such account: #{arguments.first}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1398,8 +1373,7 @@ describe Mastodon::CLI::Accounts do
|
|||
context 'when the specified account has no previous migrations' do
|
||||
it 'exits with an error message indicating that the given account has no previous migrations' do
|
||||
expect { subject }
|
||||
.to output_results('The specified account has not performed any migration')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'The specified account has not performed any migration')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1421,8 +1395,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message' do
|
||||
expect { subject }
|
||||
.to output_results('The specified account is not redirecting to its last migration target. Use --force if you want to replay the migration anyway')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'The specified account is not redirecting to its last migration target. Use --force if you want to replay the migration anyway')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1449,8 +1422,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message indicating that there is no such account' do
|
||||
expect { subject }
|
||||
.to output_results("The specified target account could not be found: #{options[:target]}")
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, "The specified target account could not be found: #{options[:target]}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1474,8 +1446,7 @@ describe Mastodon::CLI::Accounts do
|
|||
context 'when the migration record is invalid' do
|
||||
it 'exits with an error indicating that the validation failed' do
|
||||
expect { subject }
|
||||
.to output_results('Error: Validation failed')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, /Error: Validation failed/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1486,8 +1457,7 @@ describe Mastodon::CLI::Accounts do
|
|||
|
||||
it 'exits with an error message' do
|
||||
expect { subject }
|
||||
.to output_results('The specified account is redirecting to a different target account. Use --force if you want to change the migration target')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'The specified account is redirecting to a different target account. Use --force if you want to change the migration target')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -64,8 +64,7 @@ describe Mastodon::CLI::Cache do
|
|||
|
||||
it 'Exits with an error message' do
|
||||
expect { subject }
|
||||
.to output_results('Unknown')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, /Unknown/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,8 +35,7 @@ describe Mastodon::CLI::EmailDomainBlocks do
|
|||
context 'without any options' do
|
||||
it 'warns about usage and exits' do
|
||||
expect { subject }
|
||||
.to output_results('No domain(s) given')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No domain(s) given')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -72,8 +71,7 @@ describe Mastodon::CLI::EmailDomainBlocks do
|
|||
context 'without any options' do
|
||||
it 'warns about usage and exits' do
|
||||
expect { subject }
|
||||
.to output_results('No domain(s) given')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No domain(s) given')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -42,8 +42,7 @@ describe Mastodon::CLI::Feeds do
|
|||
|
||||
it 'displays an error and exits' do
|
||||
expect { subject }
|
||||
.to output_results('No such account')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No such account')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -144,8 +144,7 @@ describe Mastodon::CLI::IpBlocks do
|
|||
|
||||
it 'exits with an error message' do
|
||||
expect { subject }
|
||||
.to output_results('No IP(s) given')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No IP(s) given')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -235,8 +234,7 @@ describe Mastodon::CLI::IpBlocks do
|
|||
context 'when no IP address is provided' do
|
||||
it 'exits with an error message' do
|
||||
expect { subject }
|
||||
.to output_results('No IP(s) given')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No IP(s) given')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -104,9 +104,9 @@ describe Mastodon::CLI::Main do
|
|||
answer_hostname_incorrectly
|
||||
end
|
||||
|
||||
it 'exits silently' do
|
||||
it 'exits with mismatch error message' do
|
||||
expect { subject }
|
||||
.to raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, /Domains do not match/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -119,7 +119,7 @@ describe Mastodon::CLI::Main do
|
|||
it 'passes first step but stops before instructions' do
|
||||
expect { subject }
|
||||
.to output_results('operation WILL NOT')
|
||||
.and raise_error(SystemExit)
|
||||
.and raise_error(Thor::Error, /Self-destruct will not begin/)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -22,8 +22,7 @@ describe Mastodon::CLI::Maintenance do
|
|||
|
||||
it 'Exits with error message' do
|
||||
expect { subject }
|
||||
.to output_results('is too old')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, /is too old/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -36,7 +35,7 @@ describe Mastodon::CLI::Maintenance do
|
|||
it 'Exits with error message' do
|
||||
expect { subject }
|
||||
.to output_results('more recent')
|
||||
.and raise_error(SystemExit)
|
||||
.and raise_error(Thor::Error, /more recent/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -48,8 +47,7 @@ describe Mastodon::CLI::Maintenance do
|
|||
|
||||
it 'Exits with error message' do
|
||||
expect { subject }
|
||||
.to output_results('Sidekiq is running')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, /Sidekiq is running/)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -20,8 +20,7 @@ describe Mastodon::CLI::Media do
|
|||
|
||||
it 'warns about usage and exits' do
|
||||
expect { subject }
|
||||
.to output_results('--prune-profiles and --remove-headers should not be specified simultaneously')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, '--prune-profiles and --remove-headers should not be specified simultaneously')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -30,8 +29,7 @@ describe Mastodon::CLI::Media do
|
|||
|
||||
it 'warns about usage and exits' do
|
||||
expect { subject }
|
||||
.to output_results('--include-follows can only be used with --prune-profiles or --remove-headers')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, '--include-follows can only be used with --prune-profiles or --remove-headers')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -98,8 +96,7 @@ describe Mastodon::CLI::Media do
|
|||
|
||||
it 'warns about url and exits' do
|
||||
expect { subject }
|
||||
.to output_results('Not a media URL')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'Not a media URL')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -121,8 +118,7 @@ describe Mastodon::CLI::Media do
|
|||
context 'without any options' do
|
||||
it 'warns about usage and exits' do
|
||||
expect { subject }
|
||||
.to output_results('Specify the source')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, /Specify the source/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -147,8 +143,7 @@ describe Mastodon::CLI::Media do
|
|||
|
||||
it 'warns about usage and exits' do
|
||||
expect { subject }
|
||||
.to output_results('No such account')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, 'No such account')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -221,8 +216,7 @@ describe Mastodon::CLI::Media do
|
|||
|
||||
it 'warns about usage and exits' do
|
||||
expect { subject }
|
||||
.to output_results('azure storage driver is not supported')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, /azure storage driver is not supported/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -233,8 +227,7 @@ describe Mastodon::CLI::Media do
|
|||
|
||||
it 'warns about usage and exits' do
|
||||
expect { subject }
|
||||
.to output_results('fog storage driver is not supported')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, /fog storage driver is not supported/)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -20,8 +20,7 @@ describe Mastodon::CLI::Search do
|
|||
|
||||
it 'Exits with error message' do
|
||||
expect { subject }
|
||||
.to output_results('this concurrency setting')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, /this concurrency setting/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -30,8 +29,7 @@ describe Mastodon::CLI::Search do
|
|||
|
||||
it 'Exits with error message' do
|
||||
expect { subject }
|
||||
.to output_results('this batch_size setting')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, /this batch_size setting/)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -20,8 +20,7 @@ describe Mastodon::CLI::Statuses do
|
|||
|
||||
it 'exits with error message' do
|
||||
expect { subject }
|
||||
.to output_results('Cannot run')
|
||||
.and raise_error(SystemExit)
|
||||
.to raise_error(Thor::Error, /Cannot run/)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue