spec/lib/flare_up/cli_spec.rb in flare-up-0.9 vs spec/lib/flare_up/cli_spec.rb in flare-up-0.10
- old
+ new
@@ -1,16 +1,17 @@
describe FlareUp::CLI do
let(:required_arguments) { %w(copy TEST_DATA_SOURCE TEST_REDSHIFT_ENDPOINT TEST_DATABASE TEST_TABLE) }
- let(:required_options) do
+ let(:base_options) do
{
:data_source => 'TEST_DATA_SOURCE',
:redshift_endpoint => 'TEST_REDSHIFT_ENDPOINT',
:database => 'TEST_DATABASE',
:table => 'TEST_TABLE',
:redshift_username => 'TEST_REDSHIFT_USERNAME',
:redshift_password => 'TEST_REDSHIFT_PASSWORD',
+ :redshift_port => 5439,
:aws_access_key => 'TEST_AWS_ACCESS_KEY',
:aws_secret_key => 'TEST_AWS_SECRET_KEY',
:colorize_output => true
}
end
@@ -18,10 +19,11 @@
before do
allow(FlareUp::ENVWrap).to receive(:get).with('AWS_ACCESS_KEY_ID').and_return('TEST_AWS_ACCESS_KEY')
allow(FlareUp::ENVWrap).to receive(:get).with('AWS_SECRET_ACCESS_KEY').and_return('TEST_AWS_SECRET_KEY')
allow(FlareUp::ENVWrap).to receive(:get).with('REDSHIFT_USERNAME').and_return('TEST_REDSHIFT_USERNAME')
allow(FlareUp::ENVWrap).to receive(:get).with('REDSHIFT_PASSWORD').and_return('TEST_REDSHIFT_PASSWORD')
+ allow(FlareUp::ENVWrap).to receive(:get).with('REDSHIFT_PORT').and_return(nil)
allow(FlareUp::Boot).to receive(:boot)
end
describe '#copy' do
@@ -29,13 +31,13 @@
expect(FlareUp::Boot).to receive(:boot)
FlareUp::CLI.start(required_arguments)
end
context 'when no options are specified' do
- it 'should boot with the proper options' do
+ it 'should boot with the base options' do
FlareUp::CLI.start(required_arguments)
- expect(FlareUp::OptionStore.get_options).to eq(required_options)
+ expect(FlareUp::OptionStore.get_options).to eq(base_options)
end
end
context 'when column ordering is specified' do
it 'should boot with the proper options' do
@@ -119,10 +121,35 @@
end
end
end
end
+ describe 'port' do
+ context 'when it is specified on the CLI' do
+ it 'should boot with the proper options' do
+ FlareUp::CLI.start(required_arguments + %w(--redshift_port 1234))
+ expect(FlareUp::OptionStore.get(:redshift_port)).to eq(1234)
+ end
+ end
+ context 'when it is not specified on the CLI' do
+ context 'when it is available via ENV' do
+ it 'should boot with the key from the environment' do
+ allow(FlareUp::ENVWrap).to receive(:get).with('REDSHIFT_PORT').and_return(5678)
+ FlareUp::CLI.start(required_arguments)
+ expect(FlareUp::OptionStore.get(:redshift_port)).to eq(5678)
+ end
+ end
+ context 'when it is not available via ENV' do
+ it 'should boot with the default value' do
+ allow(FlareUp::ENVWrap).to receive(:get).with('REDSHIFT_PORT').and_return(nil)
+ FlareUp::CLI.start(required_arguments)
+ expect(FlareUp::OptionStore.get(:redshift_port)).to eq(5439)
+ end
+ end
+ end
+ end
+
end
describe 'AWS credentials' do
describe 'access key' do
@@ -179,6 +206,6 @@
end
end
-end
\ No newline at end of file
+end