@@ -83,27 +83,55 @@ module TreasureData::Command
8383 describe 'database and table arguments' do
8484 let ( :database ) { 'database' }
8585 let ( :table ) { 'table' }
86- let ( :config ) { { } }
8786
8887 before do
8988 client = double ( :client )
9089 command . stub ( :get_client ) . and_return ( client )
9190 command . stub ( :create_database_and_table_if_not_exist )
9291 command . stub ( :prepare_bulkload_job_config ) . and_return ( config )
9392 client . should_receive ( :bulk_load_issue ) . with ( database , table , { config : expect_config } ) . and_return ( 1234 )
93+ end
94+
95+ context 'set from config file' do
96+ let ( :expect_config ) {
97+ { 'out' => { 'database' => database , 'table' => table } }
98+ }
99+
100+ context 'without arguments' do
101+ let ( :option ) {
102+ List ::CommandParser . new ( "connector:issue" , [ "config" ] , [ ] , nil , [ File . join ( "spec" , "td" , "fixture" , "bulk_load.yml" ) ] , true )
103+ }
104+ let ( :config ) {
105+ { 'out' => { 'database' => database , 'table' => table } }
106+ }
107+
108+ it { expect { subject } . not_to raise_error }
109+ end
110+
111+ context 'with arguments' do
112+ let ( :option ) {
113+ List ::CommandParser . new ( "connector:issue" , [ "config" ] , [ 'database' , 'table' ] , nil , [ File . join ( "spec" , "td" , "fixture" , "bulk_load.yml" ) , '--database' , database , '--table' , table ] , true )
114+ }
115+ let ( :config ) {
116+ { 'out' => { 'database' => 'config_database' , 'table' => 'config_table' } }
117+ }
94118
95- subject
119+ it { expect { subject } . not_to raise_error }
120+ end
96121 end
97122
98123 context 'set --database and --table' do
99124 let ( :option ) {
100125 List ::CommandParser . new ( "connector:issue" , [ "config" ] , [ 'database' , 'table' ] , nil , [ File . join ( "spec" , "td" , "fixture" , "bulk_load.yml" ) , '--database' , database , '--table' , table ] , true )
101126 }
127+ let ( :config ) { { } }
102128 let ( :expect_config ) {
103129 { 'out' => { 'database' => database , 'table' => table } }
104130 }
105131
106132 it 'show warning' do
133+ subject
134+
107135 expect ( stderr_io . string ) . to include '--database is obsolete option'
108136 expect ( stderr_io . string ) . to include '--table is obsolete option'
109137 end
@@ -113,11 +141,14 @@ module TreasureData::Command
113141 let ( :option ) {
114142 List ::CommandParser . new ( "connector:issue" , [ "config" , 'database' , 'table' ] , [ ] , nil , [ database , table , File . join ( "spec" , "td" , "fixture" , "bulk_load.yml" ) ] , true )
115143 }
144+ let ( :config ) { { } }
116145 let ( :expect_config ) {
117146 { 'out' => { 'database' => database , 'table' => table } }
118147 }
119148
120149 it 'no warning' do
150+ subject
151+
121152 expect ( stderr_io . string ) . not_to include '--database is obsolete option'
122153 expect ( stderr_io . string ) . not_to include '--table is obsolete option'
123154 end
0 commit comments