Skip to content

Commit e37aa01

Browse files
author
Kevin Paulisse
committed
Add --environment / --to-environment / --from-environment
1 parent cc75054 commit e37aa01

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# frozen_string_literal: true
2+
3+
# Specify the environment to use when compiling the catalog. This is useful only in conjunction
4+
# with `--preserve-environments`.
5+
# @param parser [OptionParser object] The OptionParser argument
6+
# @param options [Hash] Options hash being constructed; this is modified in this method.
7+
OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:environment) do
8+
has_weight 502
9+
10+
def parse(parser, options)
11+
OctocatalogDiff::CatalogDiff::Cli::Options.option_globally_or_per_branch(
12+
parser: parser,
13+
options: options,
14+
cli_name: 'environment',
15+
option_name: 'environment',
16+
desc: 'Environment for catalog compilation'
17+
)
18+
end
19+
end
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../options_helper'
4+
5+
describe OctocatalogDiff::CatalogDiff::Cli::Options do
6+
describe '#opt_environment' do
7+
it 'should handle --environment' do
8+
result = run_optparse(['--environment', 'fizzbuzz'])
9+
expect(result[:from_environment]).to eq('fizzbuzz')
10+
expect(result[:to_environment]).to eq('fizzbuzz')
11+
end
12+
13+
it 'should handle --to-environment' do
14+
result = run_optparse(['--to-environment', 'fizzbuzz'])
15+
expect(result[:from_environment]).to be_nil
16+
expect(result[:to_environment]).to eq('fizzbuzz')
17+
end
18+
19+
it 'should handle --from-environment' do
20+
result = run_optparse(['--from-environment', 'fizzbuzz'])
21+
expect(result[:from_environment]).to eq('fizzbuzz')
22+
expect(result[:to_environment]).to be_nil
23+
end
24+
25+
it 'should handle --from-environment + --to-environment' do
26+
result = run_optparse(['--from-environment', 'fizzbuzz', '--to-environment', 'production'])
27+
expect(result[:from_environment]).to eq('fizzbuzz')
28+
expect(result[:to_environment]).to eq('production')
29+
end
30+
end
31+
end

0 commit comments

Comments
 (0)