Enable dry run mode when PRODUCER_DRYRUN is set
This commit is contained in:
parent
2b0e62be26
commit
658e333420
@ -15,3 +15,8 @@ Feature: CLI dry run option
|
||||
Scenario: prints a warning before any output
|
||||
When I successfully execute the recipe with option -n
|
||||
Then the output must match /\AWarning: running in dry run mode, actions will NOT be applied/
|
||||
|
||||
Scenario: enables dry run mode from the environment
|
||||
Given I set the environment variable "PRODUCER_DRYRUN"
|
||||
When I successfully execute the recipe
|
||||
Then the output must contain "running in dry run"
|
||||
|
@ -12,6 +12,7 @@ module Producer
|
||||
|
||||
ENV_VERBOSE_KEY = 'PRODUCER_VERBOSE'.freeze
|
||||
ENV_DEBUG_KEY = 'PRODUCER_DEBUG'.freeze
|
||||
ENV_DRYRUN_KEY = 'PRODUCER_DRYRUN'.freeze
|
||||
|
||||
class << self
|
||||
def run!(arguments, stdin: $stdin, stdout: $stdout, stderr: $stderr)
|
||||
@ -73,8 +74,9 @@ module Producer
|
||||
end
|
||||
|
||||
def configure_environment!(environment)
|
||||
@env.verbose = true if environment.key? ENV_VERBOSE_KEY
|
||||
@env.debug = true if environment.key? ENV_DEBUG_KEY
|
||||
@env.verbose = true if environment.key? ENV_VERBOSE_KEY
|
||||
@env.debug = true if environment.key? ENV_DEBUG_KEY
|
||||
@env.dry_run = true if environment.key? ENV_DRYRUN_KEY
|
||||
end
|
||||
|
||||
def split_arguments_lists(arguments)
|
||||
|
@ -92,6 +92,14 @@ module Producer::Core
|
||||
expect(cli.env).to be_debug
|
||||
end
|
||||
end
|
||||
|
||||
context 'when PRODUCER_DRYRUN environment variable is set' do
|
||||
before { environment['PRODUCER_DRYRUN'] = 'yes' }
|
||||
|
||||
it 'enables env dry run mode' do
|
||||
expect(cli.env).to be_dry_run
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#parse_arguments!' do
|
||||
|
Loading…
x
Reference in New Issue
Block a user