td-client 0.8.85 → 0.9.0dev1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/td/client.rb +8 -16
- data/lib/td/client/api.rb +46 -62
- data/lib/td/client/api/bulk_import.rb +2 -1
- data/lib/td/client/api/bulk_load.rb +3 -3
- data/lib/td/client/api/export.rb +0 -12
- data/lib/td/client/api/import.rb +2 -3
- data/lib/td/client/api/job.rb +71 -145
- data/lib/td/client/api/schedule.rb +1 -1
- data/lib/td/client/api_error.rb +0 -5
- data/lib/td/client/model.rb +28 -91
- data/lib/td/client/version.rb +1 -1
- data/spec/spec_helper.rb +5 -5
- data/spec/td/client/account_api_spec.rb +5 -5
- data/spec/td/client/api_spec.rb +51 -69
- data/spec/td/client/api_ssl_connection_spec.rb +1 -1
- data/spec/td/client/bulk_import_spec.rb +29 -28
- data/spec/td/client/bulk_load_spec.rb +35 -60
- data/spec/td/client/db_api_spec.rb +1 -1
- data/spec/td/client/export_api_spec.rb +1 -11
- data/spec/td/client/import_api_spec.rb +10 -85
- data/spec/td/client/job_api_spec.rb +61 -567
- data/spec/td/client/model_job_spec.rb +10 -27
- data/spec/td/client/model_schedule_spec.rb +2 -2
- data/spec/td/client/partial_delete_api_spec.rb +1 -1
- data/spec/td/client/result_api_spec.rb +3 -3
- data/spec/td/client/sched_api_spec.rb +4 -12
- data/spec/td/client/server_status_api_spec.rb +2 -2
- data/spec/td/client/spec_resources.rb +0 -1
- data/spec/td/client/table_api_spec.rb +14 -14
- data/spec/td/client/user_api_spec.rb +12 -12
- data/spec/td/client_sched_spec.rb +6 -31
- data/spec/td/client_spec.rb +0 -1
- metadata +97 -42
- data/spec/td/client/api_error_spec.rb +0 -77
- data/spec/td/client/model_schema_spec.rb +0 -134
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe APIError do
|
4
|
-
let (:message){ 'message' }
|
5
|
-
let (:api_backtrace){ double('api_backtrace') }
|
6
|
-
describe 'new' do
|
7
|
-
context '' do
|
8
|
-
it do
|
9
|
-
exc = APIError.new(message, api_backtrace)
|
10
|
-
expect(exc).to be_an(APIError)
|
11
|
-
expect(exc.message).to eq message
|
12
|
-
expect(exc.api_backtrace).to eq api_backtrace
|
13
|
-
end
|
14
|
-
end
|
15
|
-
context 'api_backtrace is ""' do
|
16
|
-
let (:api_backtrace){ '' }
|
17
|
-
it do
|
18
|
-
exc = APIError.new(message, api_backtrace)
|
19
|
-
expect(exc).to be_an(APIError)
|
20
|
-
expect(exc.message).to eq message
|
21
|
-
expect(exc.api_backtrace).to be_nil
|
22
|
-
end
|
23
|
-
end
|
24
|
-
context 'api_backtrace is nil' do
|
25
|
-
let (:api_backtrace){ nil }
|
26
|
-
it do
|
27
|
-
exc = APIError.new(message, api_backtrace)
|
28
|
-
expect(exc).to be_an(APIError)
|
29
|
-
expect(exc.message).to eq message
|
30
|
-
expect(exc.api_backtrace).to be_nil
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe AlreadyExistsError do
|
37
|
-
let (:message){ 'message' }
|
38
|
-
let (:api_backtrace){ double('api_backtrace') }
|
39
|
-
let (:conflicts_with){ '12345' }
|
40
|
-
describe 'new' do
|
41
|
-
context '' do
|
42
|
-
it do
|
43
|
-
exc = AlreadyExistsError.new(message, api_backtrace)
|
44
|
-
expect(exc).to be_an(AlreadyExistsError)
|
45
|
-
expect(exc.message).to eq message
|
46
|
-
expect(exc.api_backtrace).to eq api_backtrace
|
47
|
-
end
|
48
|
-
end
|
49
|
-
context 'api_backtrace is ""' do
|
50
|
-
let (:api_backtrace){ '' }
|
51
|
-
it do
|
52
|
-
exc = AlreadyExistsError.new(message, api_backtrace)
|
53
|
-
expect(exc).to be_an(AlreadyExistsError)
|
54
|
-
expect(exc.message).to eq message
|
55
|
-
expect(exc.api_backtrace).to be_nil
|
56
|
-
end
|
57
|
-
end
|
58
|
-
context 'api_backtrace is nil' do
|
59
|
-
let (:api_backtrace){ nil }
|
60
|
-
it do
|
61
|
-
exc = AlreadyExistsError.new(message, api_backtrace)
|
62
|
-
expect(exc).to be_an(AlreadyExistsError)
|
63
|
-
expect(exc.message).to eq message
|
64
|
-
expect(exc.api_backtrace).to be_nil
|
65
|
-
end
|
66
|
-
end
|
67
|
-
context 'conflict' do
|
68
|
-
it do
|
69
|
-
exc = AlreadyExistsError.new(message, api_backtrace, conflicts_with)
|
70
|
-
expect(exc).to be_an(AlreadyExistsError)
|
71
|
-
expect(exc.message).to eq message
|
72
|
-
expect(exc.api_backtrace).to eq api_backtrace
|
73
|
-
expect(exc.conflicts_with).to eq conflicts_with
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,134 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'td/client/spec_resources'
|
3
|
-
|
4
|
-
describe 'TreasureData::Schema::Field' do
|
5
|
-
describe '.new' do
|
6
|
-
context 'name="v"' do
|
7
|
-
it 'raises ParameterValidationError' do
|
8
|
-
expect{ Schema::Field.new('v', 'int') }.to raise_error(ParameterValidationError)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
context 'name="time"' do
|
12
|
-
it 'raises ParameterValidationError' do
|
13
|
-
expect{ Schema::Field.new('time', 'int') }.to raise_error(ParameterValidationError)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
context 'name with UTF-8' do
|
17
|
-
it 'works' do
|
18
|
-
name = "\u3042\u3044\u3046"
|
19
|
-
f = Schema::Field.new(name, 'int')
|
20
|
-
expect(f.name).to eq name
|
21
|
-
expect(f.type).to eq 'int'
|
22
|
-
expect(f.sql_alias).to be_nil
|
23
|
-
end
|
24
|
-
end
|
25
|
-
context 'with sql_alias' do
|
26
|
-
it 'raises' do
|
27
|
-
f = Schema::Field.new('t:t', 'int', 'alice')
|
28
|
-
expect(f.name).to eq 't:t'
|
29
|
-
expect(f.type).to eq 'int'
|
30
|
-
expect(f.sql_alias).to eq 'alice'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
context 'with invalid sql_alias' do
|
34
|
-
it 'raises' do
|
35
|
-
expect{ Schema::Field.new('t:t', 'int', 't:t') }.to raise_error(ParameterValidationError)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe 'TreasureData::Schema' do
|
42
|
-
describe '.parse' do
|
43
|
-
let(:columns){ ["foo:int", "BAR\u3070\u30FC:string@bar", "baz:baz!:array<double>@baz"] }
|
44
|
-
it do
|
45
|
-
sc = Schema.parse(columns)
|
46
|
-
expect(sc.fields.size).to eq 3
|
47
|
-
expect(sc.fields[0].name).to eq 'foo'
|
48
|
-
expect(sc.fields[0].type).to eq 'int'
|
49
|
-
expect(sc.fields[0].sql_alias).to be_nil
|
50
|
-
expect(sc.fields[1].name).to eq "BAR\u3070\u30FC"
|
51
|
-
expect(sc.fields[1].type).to eq 'string'
|
52
|
-
expect(sc.fields[1].sql_alias).to eq 'bar'
|
53
|
-
expect(sc.fields[2].name).to eq 'baz:baz!'
|
54
|
-
expect(sc.fields[2].type).to eq 'array<double>'
|
55
|
-
expect(sc.fields[2].sql_alias).to eq 'baz'
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe '.new' do
|
60
|
-
it do
|
61
|
-
f = Schema::Field.new('a', 'int')
|
62
|
-
sc = Schema.new([f])
|
63
|
-
expect(sc.fields[0]).to eq f
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe '#fields' do
|
68
|
-
it do
|
69
|
-
f = Schema::Field.new('a', 'int')
|
70
|
-
sc = Schema.new([f])
|
71
|
-
expect(sc.fields[0]).to eq f
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe '#add_field' do
|
76
|
-
it do
|
77
|
-
f = Schema::Field.new('a', 'int')
|
78
|
-
sc = Schema.new([f])
|
79
|
-
sc.add_field('b', 'double', 'bb')
|
80
|
-
expect(sc.fields[1].name).to eq 'b'
|
81
|
-
end
|
82
|
-
it 'raises ParameterValidationError if name is duplicated' do
|
83
|
-
f = Schema::Field.new('a', 'int')
|
84
|
-
sc = Schema.new([f])
|
85
|
-
expect{ sc.add_field('a', 'double') }.to raise_error(ParameterValidationError)
|
86
|
-
end
|
87
|
-
it 'raises ParameterValidationError if sql_alias is duplicated' do
|
88
|
-
f = Schema::Field.new('a', 'int')
|
89
|
-
sc = Schema.new([f])
|
90
|
-
expect{ sc.add_field('abc', 'double', 'a') }.to raise_error(ParameterValidationError)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe '#merge' do
|
95
|
-
it do
|
96
|
-
sc1 = Schema.parse(['foo:int', 'bar:float'])
|
97
|
-
sc2 = Schema.parse(['bar:double', 'baz:string'])
|
98
|
-
sc3 = sc1.merge(sc2)
|
99
|
-
expect(sc3.fields.size).to eq 3
|
100
|
-
expect(sc3.fields[0].name).to eq 'foo'
|
101
|
-
expect(sc3.fields[0].type).to eq 'int'
|
102
|
-
expect(sc3.fields[1].name).to eq 'bar'
|
103
|
-
expect(sc3.fields[1].type).to eq 'double'
|
104
|
-
expect(sc3.fields[2].name).to eq 'baz'
|
105
|
-
expect(sc3.fields[2].type).to eq 'string'
|
106
|
-
end
|
107
|
-
it do
|
108
|
-
sc1 = Schema.parse(['foo:int', 'bar:float'])
|
109
|
-
sc2 = Schema.parse(['bar:double@foo'])
|
110
|
-
expect{ sc1.merge(sc2) }.to raise_error(ArgumentError)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe '#to_json' do
|
115
|
-
it do
|
116
|
-
sc = Schema.parse(['foo:int', 'bar:float@baz'])
|
117
|
-
expect(sc.to_json).to eq '[["foo","int"],["bar","float","baz"]]'
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
describe '#from_json' do
|
122
|
-
it do
|
123
|
-
sc = Schema.new
|
124
|
-
sc.from_json [["foo","int"],["bar","float","baz"]]
|
125
|
-
expect(sc.fields.size).to eq 2
|
126
|
-
expect(sc.fields[0].name).to eq 'foo'
|
127
|
-
expect(sc.fields[0].type).to eq 'int'
|
128
|
-
expect(sc.fields[0].sql_alias).to be_nil
|
129
|
-
expect(sc.fields[1].name).to eq 'bar'
|
130
|
-
expect(sc.fields[1].type).to eq 'float'
|
131
|
-
expect(sc.fields[1].sql_alias).to eq 'baz'
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|