test/test_bigquery_client.rb in embulk-output-bigquery-0.4.13 vs test/test_bigquery_client.rb in embulk-output-bigquery-0.4.14

- old
+ new

@@ -94,49 +94,49 @@ client.get_dataset('something_does_not_exist') } end end - sub_test_case "create_table" do - def test_create_table + sub_test_case "create_table_if_not_exists" do + def test_create_table_if_not_exists client.delete_table('your_table_name') - assert_nothing_raised { client.create_table('your_table_name') } + assert_nothing_raised { client.create_table_if_not_exists('your_table_name') } end - def test_create_table_already_exists - assert_nothing_raised { client.create_table('your_table_name') } + def test_create_table_if_not_exists_already_exists + assert_nothing_raised { client.create_table_if_not_exists('your_table_name') } end def test_create_partitioned_table client.delete_table('your_table_name') assert_nothing_raised do - client.create_table('your_table_name$20160929', options:{ + client.create_table_if_not_exists('your_table_name$20160929', options:{ 'time_partitioning' => {'type'=>'DAY', 'expiration_ms'=>1000} }) end end end sub_test_case "delete_table" do def test_delete_table - client.create_table('your_table_name') + client.create_table_if_not_exists('your_table_name') assert_nothing_raised { client.delete_table('your_table_name') } end def test_delete_table_not_found assert_nothing_raised { client.delete_table('your_table_name') } end def test_delete_partitioned_table - client.create_table('your_table_name') + client.create_table_if_not_exists('your_table_name') assert_nothing_raised { client.delete_table('your_table_name$20160929') } end end sub_test_case "get_table" do def test_get_table - client.create_table('your_table_name') + client.create_table_if_not_exists('your_table_name') assert_nothing_raised { client.get_table('your_table_name') } end def test_get_table_not_found client.delete_table('your_table_name') @@ -144,27 +144,27 @@ client.get_table('your_table_name') } end def test_get_partitioned_table - client.create_table('your_table_name') + client.create_table_if_not_exists('your_table_name') assert_nothing_raised { client.get_table('your_table_name$20160929') } end end sub_test_case "delete_partition" do def test_delete_partition client.delete_table('your_table_name') - client.create_table('your_table_name$20160929') + client.create_table_if_not_exists('your_table_name$20160929') assert_nothing_raised { client.delete_partition('your_table_name$20160929') } ensure client.delete_table('your_table_name') end def test_delete_partition_of_non_partitioned_table client.delete_table('your_table_name') - client.create_table('your_table_name') + client.create_table_if_not_exists('your_table_name') assert_raise { client.delete_partition('your_table_name$20160929') } ensure client.delete_table('your_table_name') end @@ -173,11 +173,11 @@ end end sub_test_case "fields" do def test_fields_from_table - client.create_table('your_table_name') + client.create_table_if_not_exists('your_table_name') fields = client.fields_from_table('your_table_name') expected = [ {:type=>"BOOLEAN", :name=>"boolean"}, {:type=>"INTEGER", :name=>"long"}, {:type=>"FLOAT", :name=>"double"}, @@ -188,18 +188,18 @@ assert_equal expected, fields end end sub_test_case "copy" do - def test_create_table - client.create_table('your_table_name') + def test_create_table_if_not_exists + client.create_table_if_not_exists('your_table_name') assert_nothing_raised { client.copy('your_table_name', 'your_table_name_old') } end end sub_test_case "load" do def test_load - client.create_table('your_table_name') + client.create_table_if_not_exists('your_table_name') File.write("tmp/your_file_name.csv", record.to_csv) assert_nothing_raised { client.load("/tmp/your_file_name.csv", 'your_table_name') } end end end