td-client 0.8.66 → 0.8.67

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68f45b7f8ac2b35437c0c67488cccc901b244efa
4
- data.tar.gz: e15152f3edc04a66e74579f2fb31afa161fe87e0
3
+ metadata.gz: 13c565f827556460635d600c91a409818904e256
4
+ data.tar.gz: 2ff8ec8823177a04c69dd767040fc844dcf47e9c
5
5
  SHA512:
6
- metadata.gz: 889a0f5ec860113c7afc442915e4ef3d6d8a43b79d9bb3839874976354488ecedc8282bdc798788fbeffa74242e31d1d9ccf2c9b50b4753766991264bf20ef4d
7
- data.tar.gz: 492c0632ffbcd8d9c0cb8b6e7f02228a47d5f73c9500d1cd74104ee70e680dc024060dd201a9abff7fce857d3910bfa2fb73ad0e2e60d1ba0020069cda0a1d6e
6
+ metadata.gz: e45453b9ce95aa5054436ce1131c66c36b35b8a85e91c7b49df632b4cf940ce8969c8325f6d5bb1d6d686529e609f7cb28cd626d60de2ebb83d30074caad94b1
7
+ data.tar.gz: c0c9b534f3d0e33947387d3a73394e281e61f74b2f896220b4e9dba2a87166059d40788c8a9cc7951e8cfb39d698d987d5bc2fb09875cc87cab073a84da36888
data/lib/td/client/api.rb CHANGED
@@ -1418,15 +1418,18 @@ class API
1418
1418
  end
1419
1419
 
1420
1420
  response = client.put(target, body, header)
1421
-
1422
- unless ENV['TD_CLIENT_DEBUG'].nil?
1423
- puts "DEBUG: REST PUT response:"
1424
- puts "DEBUG: header: " + response.header.to_s
1425
- puts "DEBUG: status: " + response.code.to_s
1426
- puts "DEBUG: body: <omitted>"
1421
+ begin
1422
+ unless ENV['TD_CLIENT_DEBUG'].nil?
1423
+ puts "DEBUG: REST PUT response:"
1424
+ puts "DEBUG: header: " + response.header.to_s
1425
+ puts "DEBUG: status: " + response.code.to_s
1426
+ puts "DEBUG: body: <omitted>"
1427
+ end
1428
+ return [response.code.to_s, response.body, response]
1429
+ ensure
1430
+ # Disconnect keep-alive connection explicitly here, not by GC.
1431
+ client.reset(target) rescue nil
1427
1432
  end
1428
-
1429
- return [response.code.to_s, response.body, response]
1430
1433
  end
1431
1434
 
1432
1435
  def build_endpoint(url, host)
@@ -1,5 +1,5 @@
1
1
  module TreasureData
2
2
  class Client
3
- VERSION = '0.8.66'
3
+ VERSION = '0.8.67'
4
4
  end
5
5
  end
data/spec/spec_helper.rb CHANGED
@@ -25,7 +25,11 @@ shared_context 'common helper' do
25
25
  end
26
26
 
27
27
  let :headers do
28
- {'Accept' => '*/*', 'Accept-Encoding' => /gzip/, 'Date' => /.*/, 'User-Agent' => /Ruby/}
28
+ if RUBY_VERSION >= "2.0.0"
29
+ {'Accept' => '*/*', 'Accept-Encoding' => /gzip/, 'Date' => /.*/, 'User-Agent' => /Ruby/}
30
+ else
31
+ {'Accept' => '*/*', 'Date' => /.*/, 'User-Agent' => /Ruby/}
32
+ end
29
33
  end
30
34
 
31
35
  def stub_api_request(method, path, opts = nil)
@@ -11,8 +11,8 @@ describe 'BulkImport API' do
11
11
 
12
12
  describe 'create_bulk_import' do
13
13
  it 'should create a new bulk_import' do
14
- stub_api_request(:post, "/v3/bulk_import/create/#{e(bi_name)}/#{e(db_name)}/#{e(table_name)}")
15
- .to_return(:body => {'bulk_import' => bi_name}.to_json)
14
+ stub_api_request(:post, "/v3/bulk_import/create/#{e(bi_name)}/#{e(db_name)}/#{e(table_name)}").
15
+ to_return(:body => {'bulk_import' => bi_name}.to_json)
16
16
 
17
17
  api.create_bulk_import(bi_name, db_name, table_name).should be_nil
18
18
  end
@@ -20,8 +20,8 @@ describe 'BulkImport API' do
20
20
  it 'should return 422 error with invalid name' do
21
21
  name = 'D'
22
22
  err_msg = "Validation failed: Name is too short" # " (minimum is 3 characters)"
23
- stub_api_request(:post, "/v3/bulk_import/create/#{e(name)}/#{e(db_name)}/#{e(table_name)}")
24
- .to_return(:status => 422, :body => {'message' => err_msg}.to_json)
23
+ stub_api_request(:post, "/v3/bulk_import/create/#{e(name)}/#{e(db_name)}/#{e(table_name)}").
24
+ to_return(:status => 422, :body => {'message' => err_msg}.to_json)
25
25
 
26
26
  expect {
27
27
  api.create_bulk_import(name, db_name, table_name)
@@ -31,8 +31,8 @@ describe 'BulkImport API' do
31
31
  it 'should return 404 error with non exist database name' do
32
32
  db = 'no_such_db'
33
33
  err_msg = "Couldn't find UserDatabase with name = #{db}"
34
- stub_api_request(:post, "/v3/bulk_import/create/#{e(bi_name)}/#{e(db)}/#{e(table_name)}")
35
- .to_return(:status => 404, :body => {'message' => err_msg}.to_json)
34
+ stub_api_request(:post, "/v3/bulk_import/create/#{e(bi_name)}/#{e(db)}/#{e(table_name)}").
35
+ to_return(:status => 404, :body => {'message' => err_msg}.to_json)
36
36
 
37
37
  expect {
38
38
  api.create_bulk_import(bi_name, db, table_name)
@@ -42,8 +42,8 @@ describe 'BulkImport API' do
42
42
  it 'should return 404 error with non exist table name' do
43
43
  table = 'no_such_table'
44
44
  err_msg = "Couldn't find UserTableReference with name = #{table}"
45
- stub_api_request(:post, "/v3/bulk_import/create/#{e(bi_name)}/#{e(db_name)}/#{e(table)}")
46
- .to_return(:status => 404, :body => {'message' => err_msg}.to_json)
45
+ stub_api_request(:post, "/v3/bulk_import/create/#{e(bi_name)}/#{e(db_name)}/#{e(table)}").
46
+ to_return(:status => 404, :body => {'message' => err_msg}.to_json)
47
47
 
48
48
  expect {
49
49
  api.create_bulk_import(bi_name, db_name, table)
@@ -15,8 +15,8 @@ describe 'Database API' do
15
15
 
16
16
  describe "'create_database' API" do
17
17
  it 'should create a new database' do
18
- stub_api_request(:post, "/v3/database/create/#{e(db_name)}")
19
- .to_return(:body => {'database' => db_name}.to_json)
18
+ stub_api_request(:post, "/v3/database/create/#{e(db_name)}").
19
+ to_return(:body => {'database' => db_name}.to_json)
20
20
 
21
21
  api.create_database(db_name).should be true
22
22
  end
@@ -24,8 +24,8 @@ describe 'Database API' do
24
24
  it 'should return 400 error with invalid name' do
25
25
  invalid_name = 'a'
26
26
  err_msg = "Name must be 3 to 256 characters, got #{invalid_name.length} characters. name = '#{invalid_name}'"
27
- stub_api_request(:post, "/v3/database/create/#{e(invalid_name)}")
28
- .to_return(:status => 400, :body => {'message' => err_msg}.to_json)
27
+ stub_api_request(:post, "/v3/database/create/#{e(invalid_name)}").
28
+ to_return(:status => 400, :body => {'message' => err_msg}.to_json)
29
29
 
30
30
  expect {
31
31
  api.create_database(invalid_name)
@@ -34,8 +34,8 @@ describe 'Database API' do
34
34
 
35
35
  it 'should return 409 error with duplicated name' do
36
36
  err_msg = "Database #{db_name} already exists"
37
- stub_api_request(:post, "/v3/database/create/#{e(db_name)}")
38
- .to_return(:status => 409, :body => {'message' => err_msg}.to_json)
37
+ stub_api_request(:post, "/v3/database/create/#{e(db_name)}").
38
+ to_return(:status => 409, :body => {'message' => err_msg}.to_json)
39
39
 
40
40
  expect {
41
41
  api.create_database(db_name)
@@ -51,8 +51,8 @@ describe 'Database API' do
51
51
  ["db_3", 333, "2013-03-23 03:53:43 UTC", "2014-03-23 03:53:43 UTC", nil, "import_only"],
52
52
  ["db_4", 444, "2013-04-24 04:54:44 UTC", "2014-04-24 04:54:44 UTC", nil, "query_only"]
53
53
  ]
54
- stub_api_request(:get, "/v3/database/list")
55
- .to_return(:body => {'databases' => [
54
+ stub_api_request(:get, "/v3/database/list").
55
+ to_return(:body => {'databases' => [
56
56
  {'name' => databases[0][0], 'count' => databases[0][1], 'created_at' => databases[0][2], 'updated_at' => databases[0][3], 'organization' => databases[0][4], 'permission' => databases[0][5]},
57
57
  {'name' => databases[1][0], 'count' => databases[1][1], 'created_at' => databases[1][2], 'updated_at' => databases[1][3], 'organization' => databases[1][4], 'permission' => databases[1][5]},
58
58
  {'name' => databases[2][0], 'count' => databases[2][1], 'created_at' => databases[2][2], 'updated_at' => databases[2][3], 'organization' => databases[2][4], 'permission' => databases[2][5]},
@@ -74,15 +74,15 @@ describe 'Database API' do
74
74
  ["db_3", 333, "2013-03-23 03:53:43 UTC", "2014-03-23 03:53:43 UTC", nil, "import_only"],
75
75
  ["db_4", 444, "2013-04-24 04:54:44 UTC", "2014-04-24 04:54:44 UTC", nil, "query_only"]
76
76
  ]
77
- stub_api_request(:get, "/v3/database/list")
78
- .to_return(:body => {'databases' => [
77
+ stub_api_request(:get, "/v3/database/list").
78
+ to_return(:body => {'databases' => [
79
79
  {'name' => databases[0][0], 'count' => databases[0][1], 'created_at' => databases[0][2], 'updated_at' => databases[0][3], 'organization' => databases[0][4], 'permission' => databases[0][5]},
80
80
  {'name' => databases[1][0], 'count' => databases[1][1], 'created_at' => databases[1][2], 'updated_at' => databases[1][3], 'organization' => databases[1][4], 'permission' => databases[1][5]},
81
81
  {'name' => databases[2][0], 'count' => databases[2][1], 'created_at' => databases[2][2], 'updated_at' => databases[2][3], 'organization' => databases[2][4], 'permission' => databases[2][5]},
82
82
  {'name' => databases[3][0], 'count' => databases[3][1], 'created_at' => databases[3][2], 'updated_at' => databases[3][3], 'organization' => databases[3][4], 'permission' => databases[3][5]}
83
83
  ]}.to_json)
84
84
 
85
- db_list = client.databases
85
+ db_list = client.databases.sort_by { |e| e.name }
86
86
  databases.length.times {|i|
87
87
  expect(db_list[i].name).to eq(databases[i][0])
88
88
  expect(db_list[i].count).to eq(databases[i][1])
@@ -102,8 +102,8 @@ describe 'Database API' do
102
102
  ["db_3", 333, "2013-03-23 03:53:43 UTC", "2014-03-23 03:53:43 UTC", nil, "import_only"],
103
103
  ["db_4", 444, "2013-04-24 04:54:44 UTC", "2014-04-24 04:54:44 UTC", nil, "query_only"]
104
104
  ]
105
- stub_api_request(:get, "/v3/database/list")
106
- .to_return(:body => {'databases' => [
105
+ stub_api_request(:get, "/v3/database/list").
106
+ to_return(:body => {'databases' => [
107
107
  {'name' => databases[0][0], 'count' => databases[0][1], 'created_at' => databases[0][2], 'updated_at' => databases[0][3], 'organization' => databases[0][4], 'permission' => databases[0][5]},
108
108
  {'name' => databases[1][0], 'count' => databases[1][1], 'created_at' => databases[1][2], 'updated_at' => databases[1][3], 'organization' => databases[1][4], 'permission' => databases[1][5]},
109
109
  {'name' => databases[2][0], 'count' => databases[2][1], 'created_at' => databases[2][2], 'updated_at' => databases[2][3], 'organization' => databases[2][4], 'permission' => databases[2][5]},
@@ -17,8 +17,8 @@ describe 'Export API' do
17
17
  it 'should export successfully' do
18
18
  # TODO: Use correnty values
19
19
  params = {'file_format' => 'json.gz', 'bucket' => 'bin', 'access_key_id' => 'id', 'secret_access_key' => 'secret'}
20
- stub_api_request(:post, "/v3/export/run/#{e(db_name)}/#{e(table_name)}").with(:body => params.merge('storage_type' => storage_type))
21
- .to_return(:body => {'database' => db_name, 'job_id' => '1', 'debug' => {}}.to_json)
20
+ stub_api_request(:post, "/v3/export/run/#{e(db_name)}/#{e(table_name)}").with(:body => params.merge('storage_type' => storage_type)).
21
+ to_return(:body => {'database' => db_name, 'job_id' => '1', 'debug' => {}}.to_json)
22
22
 
23
23
  api.export(db_name, table_name, storage_type, params).should == '1'
24
24
  end
@@ -27,8 +27,8 @@ describe 'Export API' do
27
27
  invalid_type = 'gridfs'
28
28
  params = {'storage_type' => invalid_type}
29
29
  err_msg = "Only s3 output type is supported: #{invalid_type}"
30
- stub_api_request(:post, "/v3/export/run/#{e(db_name)}/#{e(table_name)}").with(:body => params)
31
- .to_return(:status => 400, :body => {'message' => err_msg}.to_json)
30
+ stub_api_request(:post, "/v3/export/run/#{e(db_name)}/#{e(table_name)}").with(:body => params).
31
+ to_return(:status => 400, :body => {'message' => err_msg}.to_json)
32
32
 
33
33
  expect {
34
34
  api.export(db_name, table_name, invalid_type)
@@ -24,8 +24,8 @@ describe 'PartialDelete API' do
24
24
 
25
25
  it 'should partial_delete successfully' do
26
26
  # TODO: Use correnty values
27
- stub_api_request(:post, "/v3/table/partialdelete/#{e(db_name)}/#{e(table_name)}").with(:body => from_to)
28
- .to_return(:body => {'database' => db_name, 'table' => table_name, 'job_id' => '1'}.to_json)
27
+ stub_api_request(:post, "/v3/table/partialdelete/#{e(db_name)}/#{e(table_name)}").with(:body => from_to).
28
+ to_return(:body => {'database' => db_name, 'table' => table_name, 'job_id' => '1'}.to_json)
29
29
 
30
30
  api.partial_delete(db_name, table_name, to, from).should == '1'
31
31
  end
@@ -33,8 +33,8 @@ describe 'PartialDelete API' do
33
33
  it 'should return 404 error with non exist database name' do
34
34
  db = 'no_such_db'
35
35
  err_msg = "Couldn't find UserDatabase with name = #{db}"
36
- stub_api_request(:post, "/v3/table/partialdelete/#{e(db)}/#{e(table_name)}").with(:body => from_to)
37
- .to_return(:status => 404, :body => {'message' => err_msg}.to_json)
36
+ stub_api_request(:post, "/v3/table/partialdelete/#{e(db)}/#{e(table_name)}").with(:body => from_to).
37
+ to_return(:status => 404, :body => {'message' => err_msg}.to_json)
38
38
 
39
39
  expect {
40
40
  api.partial_delete(db, table_name, to, from)
@@ -44,8 +44,8 @@ describe 'PartialDelete API' do
44
44
  it 'should return 404 error with non exist table name' do
45
45
  table = 'no_such_table'
46
46
  err_msg = "Unknown table: #{table}"
47
- stub_api_request(:post, "/v3/table/partialdelete/#{e(db_name)}/#{e(table)}").with(:body => from_to)
48
- .to_return(:status => 404, :body => {'message' => err_msg}.to_json)
47
+ stub_api_request(:post, "/v3/table/partialdelete/#{e(db_name)}/#{e(table)}").with(:body => from_to).
48
+ to_return(:status => 404, :body => {'message' => err_msg}.to_json)
49
49
 
50
50
  expect {
51
51
  api.partial_delete(db_name, table, to, from)
@@ -12,7 +12,7 @@ describe 'Result API' do
12
12
  describe 'create_result' do
13
13
  it 'should create a new result' do
14
14
  params = {'url' => result_url}
15
- stub_api_request(:post, "/v3/result/create/#{e(result_name)}").with(:body => params).to_return(:body => {'result' => result_name})
15
+ stub_api_request(:post, "/v3/result/create/#{e(result_name)}").with(:body => params).to_return(:body => {'result' => result_name}.to_json)
16
16
 
17
17
  api.create_result(result_name, result_url).should be true
18
18
  end
@@ -21,8 +21,8 @@ describe 'Result API' do
21
21
  name = '1'
22
22
  params = {'url' => result_url}
23
23
  err_msg = "Validation failed: Name is too short" # " (minimum is 3 characters)"
24
- stub_api_request(:post, "/v3/result/create/#{e(name)}").with(:body => params)
25
- .to_return(:status => 422, :body => {'message' => err_msg}.to_json)
24
+ stub_api_request(:post, "/v3/result/create/#{e(name)}").with(:body => params).
25
+ to_return(:status => 422, :body => {'message' => err_msg}.to_json)
26
26
 
27
27
  expect {
28
28
  api.create_result(name, result_url)
@@ -32,8 +32,8 @@ describe 'Result API' do
32
32
  it 'should return 422 error without url' do
33
33
  params = {'url' => 'false'} # I want to use nil, but nil doesn't work on WebMock...
34
34
  err_msg = "'url' parameter is required"
35
- stub_api_request(:post, "/v3/result/create/#{e(result_name)}").with(:body => params)
36
- .to_return(:status => 422, :body => {'message' => err_msg}.to_json)
35
+ stub_api_request(:post, "/v3/result/create/#{e(result_name)}").with(:body => params).
36
+ to_return(:status => 422, :body => {'message' => err_msg}.to_json)
37
37
 
38
38
  expect {
39
39
  api.create_result(result_name, false)
@@ -43,8 +43,8 @@ describe 'Result API' do
43
43
  it 'should return 409 error with duplicated name' do
44
44
  params = {'url' => result_url}
45
45
  err_msg = "Result must be unique"
46
- stub_api_request(:post, "/v3/result/create/#{e(result_name)}").with(:body => params)
47
- .to_return(:status => 409, :body => {'message' => err_msg}.to_json)
46
+ stub_api_request(:post, "/v3/result/create/#{e(result_name)}").with(:body => params).
47
+ to_return(:status => 409, :body => {'message' => err_msg}.to_json)
48
48
 
49
49
  expect {
50
50
  api.create_result(result_name, result_url)
@@ -16,9 +16,9 @@ describe 'Schedule API' do
16
16
 
17
17
  it 'should create a new schedule' do
18
18
  start = Time.now
19
- stub_api_request(:post, "/v3/schedule/create/#{e(sched_name)}")
20
- .with(:body => opts.merge('type' => 'hive'))
21
- .to_return(:body => {'name' => sched_name, 'start' => start.to_s}.to_json)
19
+ stub_api_request(:post, "/v3/schedule/create/#{e(sched_name)}").
20
+ with(:body => opts.merge('type' => 'hive')).
21
+ to_return(:body => {'name' => sched_name, 'start' => start.to_s}.to_json)
22
22
 
23
23
  api.create_schedule(sched_name, opts.merge('type' => 'hive')).should == start.to_s
24
24
  end
@@ -26,9 +26,9 @@ describe 'Schedule API' do
26
26
  it 'should return 422 error with invalid name' do
27
27
  name = '1'
28
28
  err_msg = "Validation failed: Name is too short" # " (minimum is 3 characters)"
29
- stub_api_request(:post, "/v3/schedule/create/#{e(name)}")
30
- .with(:body => opts.merge('type' => 'hive'))
31
- .to_return(:status => 422, :body => {'message' => err_msg}.to_json)
29
+ stub_api_request(:post, "/v3/schedule/create/#{e(name)}").
30
+ with(:body => opts.merge('type' => 'hive')).
31
+ to_return(:status => 422, :body => {'message' => err_msg}.to_json)
32
32
 
33
33
  expect {
34
34
  api.create_schedule(name, opts.merge('type' => 'hive'))
@@ -45,9 +45,9 @@ describe 'Schedule API' do
45
45
  end
46
46
 
47
47
  it 'should not return 414 even if the query text is very long' do
48
- stub_api_request(:post, "/v3/schedule/update/#{e(sched_name)}")
49
- .with(:body => opts.merge('type' => 'pig'))
50
- .to_return(:body => {'name' => sched_name, 'query' => pig_query}.to_json)
48
+ stub_api_request(:post, "/v3/schedule/update/#{e(sched_name)}").
49
+ with(:body => opts.merge('type' => 'pig')).
50
+ to_return(:body => {'name' => sched_name, 'query' => pig_query}.to_json)
51
51
 
52
52
  expect {
53
53
  api.update_schedule(sched_name, opts.merge('type' => 'pig'))
@@ -55,12 +55,12 @@ describe 'Schedule API' do
55
55
  end
56
56
 
57
57
  it 'should update the schedule with the new query' do
58
- stub_api_request(:post, "/v3/schedule/update/#{e(sched_name)}")
59
- .with(:body => opts.merge('type' => 'pig'))
60
- .to_return(:body => {'name' => sched_name, 'query' => pig_query}.to_json)
58
+ stub_api_request(:post, "/v3/schedule/update/#{e(sched_name)}").
59
+ with(:body => opts.merge('type' => 'pig')).
60
+ to_return(:body => {'name' => sched_name, 'query' => pig_query}.to_json)
61
61
 
62
- stub_api_request(:get, "/v3/schedule/list")
63
- .to_return(:body => {'schedules' => [{'name' => sched_name, 'query' => pig_query}]}.to_json)
62
+ stub_api_request(:get, "/v3/schedule/list").
63
+ to_return(:body => {'schedules' => [{'name' => sched_name, 'query' => pig_query}]}.to_json)
64
64
 
65
65
  expect(api.list_schedules.first[2]).to eq(pig_query)
66
66
  end
@@ -16,8 +16,8 @@ describe 'Table API' do
16
16
  describe "'create_log_table' API" do
17
17
  it 'should return 404 error if the database does not exist' do
18
18
  err_msg = "Create log table failed: Couldn't find UserDatabase with name = #{db_name}"
19
- stub_api_request(:post, "/v3/table/create/#{e db_name}/#{e(table_name)}/log")
20
- .to_return(:status => 404, :body => {'message' => err_msg}.to_json)
19
+ stub_api_request(:post, "/v3/table/create/#{e db_name}/#{e(table_name)}/log").
20
+ to_return(:status => 404, :body => {'message' => err_msg}.to_json)
21
21
 
22
22
  expect {
23
23
  api.create_log_table(db_name, table_name)
@@ -25,16 +25,16 @@ describe 'Table API' do
25
25
  end
26
26
 
27
27
  it 'should create a new table if the database exists' do
28
- stub_api_request(:post, "/v3/table/create/#{e db_name}/#{e(table_name)}/log")
29
- .to_return(:body => {'database' => db_name, 'table' => table_name, 'type' => 'log'}.to_json)
28
+ stub_api_request(:post, "/v3/table/create/#{e db_name}/#{e(table_name)}/log").
29
+ to_return(:body => {'database' => db_name, 'table' => table_name, 'type' => 'log'}.to_json)
30
30
  api.create_log_table(db_name, table_name).should be true
31
31
  end
32
32
 
33
33
  it 'should return 400 error with invalid name' do
34
34
  invalid_name = 'a'
35
35
  err_msg = "Name must be 3 to 256 characters, got #{invalid_name.length} characters. name = '#{invalid_name}'"
36
- stub_api_request(:post, "/v3/table/create/#{e db_name}/#{e invalid_name}/log")
37
- .to_return(:status => 400, :body => {'message' => err_msg}.to_json)
36
+ stub_api_request(:post, "/v3/table/create/#{e db_name}/#{e invalid_name}/log").
37
+ to_return(:status => 400, :body => {'message' => err_msg}.to_json)
38
38
 
39
39
  expect {
40
40
  api.create_log_table(db_name, invalid_name)
@@ -43,8 +43,8 @@ describe 'Table API' do
43
43
 
44
44
  it 'should return 409 error with duplicated name' do
45
45
  err_msg = "Table #{table_name} already exists"
46
- stub_api_request(:post, "/v3/table/create/#{e db_name}/#{e table_name}/log")
47
- .to_return(:status => 409, :body => {'message' => err_msg}.to_json)
46
+ stub_api_request(:post, "/v3/table/create/#{e db_name}/#{e table_name}/log").
47
+ to_return(:status => 409, :body => {'message' => err_msg}.to_json)
48
48
 
49
49
  expect {
50
50
  api.create_log_table(db_name, table_name)
@@ -60,8 +60,8 @@ describe 'Table API' do
60
60
  ["table_3", "item", "[[\"time\",\"long\"],[\"value\",\"string\"]]", 333, "2013-03-23 03:53:43 UTC", "2014-03-23 03:53:43 UTC"],
61
61
  ["table_4", "log", "[[\"time\",\"long\"],[\"value\",\"long\"]]", 444, "2013-04-24 04:54:44 UTC", "2014-04-24 04:54:44 UTC"]
62
62
  ]
63
- stub_api_request(:get, "/v3/table/list/#{e db_name}")
64
- .to_return(:body => {'tables' => [
63
+ stub_api_request(:get, "/v3/table/list/#{e db_name}").
64
+ to_return(:body => {'tables' => [
65
65
  {'name' => tables[0][0], 'type' => tables[0][1], 'schema' => tables[0][2], 'count' => tables[0][3], 'created_at' => tables[0][4], 'updated_at' => tables[0][5]},
66
66
  {'name' => tables[1][0], 'type' => tables[1][1], 'schema' => tables[1][2], 'count' => tables[1][3], 'created_at' => tables[1][4], 'updated_at' => tables[1][5]},
67
67
  {'name' => tables[2][0], 'type' => tables[2][1], 'schema' => tables[2][2], 'count' => tables[2][3], 'created_at' => tables[2][4], 'updated_at' => tables[2][5]},
@@ -87,15 +87,15 @@ describe 'Table API' do
87
87
  ["table_3", "item", "[[\"time\",\"long\"],[\"value\",\"string\"]]", 333, "2013-03-23 03:53:43 UTC", "2014-03-23 03:53:43 UTC"],
88
88
  ["table_4", "log", "[[\"time\",\"long\"],[\"value\",\"long\"]]", 444, "2013-04-24 04:54:44 UTC", "2014-04-24 04:54:44 UTC"]
89
89
  ]
90
- stub_api_request(:get, "/v3/table/list/#{e db_name}")
91
- .to_return(:body => {'tables' => [
90
+ stub_api_request(:get, "/v3/table/list/#{e db_name}").
91
+ to_return(:body => {'tables' => [
92
92
  {'name' => tables[0][0], 'type' => tables[0][1], 'schema' => tables[0][2], 'count' => tables[0][3], 'created_at' => tables[0][4], 'updated_at' => tables[0][5]},
93
93
  {'name' => tables[1][0], 'type' => tables[1][1], 'schema' => tables[1][2], 'count' => tables[1][3], 'created_at' => tables[1][4], 'updated_at' => tables[1][5]},
94
94
  {'name' => tables[2][0], 'type' => tables[2][1], 'schema' => tables[2][2], 'count' => tables[2][3], 'created_at' => tables[2][4], 'updated_at' => tables[2][5]},
95
95
  {'name' => tables[3][0], 'type' => tables[3][1], 'schema' => tables[3][2], 'count' => tables[3][3], 'created_at' => tables[3][4], 'updated_at' => tables[3][5]}
96
96
  ]}.to_json)
97
97
 
98
- table_list = client.tables(db_name)
98
+ table_list = client.tables(db_name).sort_by { |e| e.name }
99
99
 
100
100
  db_count = 0
101
101
  tables.each {|table|
@@ -103,8 +103,8 @@ describe 'Table API' do
103
103
  }
104
104
 
105
105
  # REST API call to fetch the database permission
106
- stub_api_request(:get, "/v3/database/list")
107
- .to_return(:body => {'databases' => [
106
+ stub_api_request(:get, "/v3/database/list").
107
+ to_return(:body => {'databases' => [
108
108
  {'name' => db_name, 'count' => db_count, 'created_at' => tables[0][4], 'updated_at' => tables[0][5], 'permission' => 'full_access'}
109
109
  ]}.to_json)
110
110
 
@@ -118,16 +118,16 @@ describe 'Table API' do
118
118
  expect(table_list[i].updated_at).to eq(Time.parse(tables[i][5]))
119
119
 
120
120
  # REST API call to fetch the database permission
121
- stub_api_request(:get, "/v3/database/list")
122
- .to_return(:body => {'databases' => [
121
+ stub_api_request(:get, "/v3/database/list").
122
+ to_return(:body => {'databases' => [
123
123
  {'name' => db_name, 'count' => db_count, 'created_at' => tables[0][4], 'updated_at' => tables[0][5], 'permission' => 'full_access'}
124
124
  ]}.to_json)
125
125
  expect(table_list[i].permission).to eq(:full_access)
126
126
 
127
127
  # set up a trap to check this call never happens
128
128
  # - if it did, the next assertion on the count would fail
129
- stub_api_request(:get, "/v3/database/list")
130
- .to_return(:body => {'databases' => [
129
+ stub_api_request(:get, "/v3/database/list").
130
+ to_return(:body => {'databases' => [
131
131
  {'name' => db_name, 'count' => db_count + 100, 'created_at' => tables[0][4], 'updated_at' => tables[0][5], 'permission' => 'full_access'}
132
132
  ]}.to_json)
133
133
  expect(table_list[i].database.count).to eq(db_count)
@@ -143,8 +143,8 @@ describe 'Table API' do
143
143
  ["table_3", "item", "[[\"time\",\"long\"],[\"value\",\"string\"]]", 333, "2013-03-23 03:53:43 UTC", "2014-03-23 03:53:43 UTC"],
144
144
  ["table_4", "log", "[[\"time\",\"long\"],[\"value\",\"long\"]]", 444, "2013-04-24 04:54:44 UTC", "2014-04-24 04:54:44 UTC"]
145
145
  ]
146
- stub_api_request(:get, "/v3/table/list/#{e db_name}")
147
- .to_return(:body => {'tables' => [
146
+ stub_api_request(:get, "/v3/table/list/#{e db_name}").
147
+ to_return(:body => {'tables' => [
148
148
  {'name' => tables[0][0], 'type' => tables[0][1], 'schema' => tables[0][2], 'count' => tables[0][3], 'created_at' => tables[0][4], 'updated_at' => tables[0][5]},
149
149
  {'name' => tables[1][0], 'type' => tables[1][1], 'schema' => tables[1][2], 'count' => tables[1][3], 'created_at' => tables[1][4], 'updated_at' => tables[1][5]},
150
150
  {'name' => tables[2][0], 'type' => tables[2][1], 'schema' => tables[2][2], 'count' => tables[2][3], 'created_at' => tables[2][4], 'updated_at' => tables[2][5]},
metadata CHANGED
@@ -1,141 +1,141 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: td-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.66
4
+ version: 0.8.67
5
5
  platform: ruby
6
6
  authors:
7
7
  - Treasure Data, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-16 00:00:00.000000000 Z
11
+ date: 2014-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.4.4
20
- - - "!="
20
+ - - '!='
21
21
  - !ruby/object:Gem::Version
22
22
  version: 0.5.0
23
- - - "!="
23
+ - - '!='
24
24
  - !ruby/object:Gem::Version
25
25
  version: 0.5.1
26
- - - "!="
26
+ - - '!='
27
27
  - !ruby/object:Gem::Version
28
28
  version: 0.5.2
29
- - - "!="
29
+ - - '!='
30
30
  - !ruby/object:Gem::Version
31
31
  version: 0.5.3
32
- - - "<"
32
+ - - <
33
33
  - !ruby/object:Gem::Version
34
34
  version: 0.6.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - '>='
40
40
  - !ruby/object:Gem::Version
41
41
  version: 0.4.4
42
- - - "!="
42
+ - - '!='
43
43
  - !ruby/object:Gem::Version
44
44
  version: 0.5.0
45
- - - "!="
45
+ - - '!='
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.5.1
48
- - - "!="
48
+ - - '!='
49
49
  - !ruby/object:Gem::Version
50
50
  version: 0.5.2
51
- - - "!="
51
+ - - '!='
52
52
  - !ruby/object:Gem::Version
53
53
  version: 0.5.3
54
- - - "<"
54
+ - - <
55
55
  - !ruby/object:Gem::Version
56
56
  version: 0.6.0
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: json
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ">="
61
+ - - '>='
62
62
  - !ruby/object:Gem::Version
63
63
  version: 1.7.6
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ">="
68
+ - - '>='
69
69
  - !ruby/object:Gem::Version
70
70
  version: 1.7.6
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: httpclient
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - "~>"
75
+ - - ~>
76
76
  - !ruby/object:Gem::Version
77
77
  version: 2.4.0
78
78
  type: :runtime
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - "~>"
82
+ - - ~>
83
83
  - !ruby/object:Gem::Version
84
84
  version: 2.4.0
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: rspec
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - "~>"
89
+ - - ~>
90
90
  - !ruby/object:Gem::Version
91
91
  version: '2.8'
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - "~>"
96
+ - - ~>
97
97
  - !ruby/object:Gem::Version
98
98
  version: '2.8'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: webmock
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - "~>"
103
+ - - ~>
104
104
  - !ruby/object:Gem::Version
105
105
  version: '1.16'
106
106
  type: :development
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
- - - "~>"
110
+ - - ~>
111
111
  - !ruby/object:Gem::Version
112
112
  version: '1.16'
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: simplecov
115
115
  requirement: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - ">="
117
+ - - '>='
118
118
  - !ruby/object:Gem::Version
119
119
  version: 0.5.4
120
120
  type: :development
121
121
  prerelease: false
122
122
  version_requirements: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - ">="
124
+ - - '>='
125
125
  - !ruby/object:Gem::Version
126
126
  version: 0.5.4
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: rake
129
129
  requirement: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - ">="
131
+ - - '>='
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  type: :development
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - ">="
138
+ - - '>='
139
139
  - !ruby/object:Gem::Version
140
140
  version: '0'
141
141
  description: Treasure Data API library for Ruby
@@ -144,13 +144,13 @@ executables: []
144
144
  extensions: []
145
145
  extra_rdoc_files: []
146
146
  files:
147
- - data/ca-bundle.crt
148
- - lib/td-client.rb
149
- - lib/td/client.rb
150
147
  - lib/td/client/api.rb
151
148
  - lib/td/client/compat_gzip_reader.rb
152
149
  - lib/td/client/model.rb
153
150
  - lib/td/client/version.rb
151
+ - lib/td/client.rb
152
+ - lib/td-client.rb
153
+ - data/ca-bundle.crt
154
154
  - spec/spec_helper.rb
155
155
  - spec/td/client/api_spec.rb
156
156
  - spec/td/client/api_ssl_connection_spec.rb
@@ -172,17 +172,17 @@ require_paths:
172
172
  - lib
173
173
  required_ruby_version: !ruby/object:Gem::Requirement
174
174
  requirements:
175
- - - ">="
175
+ - - '>='
176
176
  - !ruby/object:Gem::Version
177
177
  version: '0'
178
178
  required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  requirements:
180
- - - ">="
180
+ - - '>='
181
181
  - !ruby/object:Gem::Version
182
182
  version: '0'
183
183
  requirements: []
184
184
  rubyforge_project:
185
- rubygems_version: 2.2.2
185
+ rubygems_version: 2.0.14
186
186
  signing_key:
187
187
  specification_version: 4
188
188
  summary: Treasure Data API library for Ruby