td-logger 0.3.24 → 0.3.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.coveralls.yml +1 -0
- data/.gitignore +2 -0
- data/.travis.yml +10 -2
- data/ChangeLog +6 -0
- data/README.rdoc +5 -2
- data/VERSION +1 -1
- data/appveyor.yml +17 -0
- data/lib/td/logger/td_logger.rb +20 -5
- data/lib/td/logger/version.rb +1 -1
- data/spec/spec_helper.rb +18 -0
- data/spec/td/logger/agent/config_spec.rb +260 -0
- data/spec/td/logger/agent/rack_spec.rb +37 -0
- data/spec/td/logger/agent/rails_spec.rb +155 -0
- data/spec/td/logger/event_spec.rb +136 -0
- data/spec/td/logger/treasure_data_logger_spec.rb +669 -0
- data/spec/td/logger_spec.rb +128 -0
- data/td-logger.gemspec +5 -3
- metadata +75 -39
- data/spec/event_spec.rb +0 -46
- data/spec/rails_config_spec.rb +0 -159
- data/spec/td_logger_spec.rb +0 -83
data/spec/td_logger_spec.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe TreasureData::Logger::TreasureDataLogger do
|
5
|
-
context 'init' do
|
6
|
-
it 'with apikey' do
|
7
|
-
td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey => 'test_1')
|
8
|
-
td.instance_variable_get(:@client).api.apikey.should == 'test_1'
|
9
|
-
td.instance_variable_get(:@client).api.instance_variable_get(:@ssl).should be_false
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'with apikey and use_ssl' do
|
13
|
-
td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey => 'test_1', :use_ssl => true)
|
14
|
-
td.instance_variable_get(:@client).api.apikey.should == 'test_1'
|
15
|
-
td.instance_variable_get(:@client).api.instance_variable_get(:@ssl).should be_true
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'with apikey and ssl' do
|
19
|
-
td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey => 'test_1', :ssl => true)
|
20
|
-
td.instance_variable_get(:@client).api.apikey.should == 'test_1'
|
21
|
-
td.instance_variable_get(:@client).api.instance_variable_get(:@ssl).should be_true
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'with apikey and HTTP endpoint' do
|
25
|
-
td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey => 'test_1', :endpoint => "http://idontexi.st")
|
26
|
-
td.instance_variable_get(:@client).api.apikey.should == 'test_1'
|
27
|
-
td.instance_variable_get(:@client).api.instance_variable_get(:@host).should == "idontexi.st"
|
28
|
-
td.instance_variable_get(:@client).api.instance_variable_get(:@port).should == 80
|
29
|
-
td.instance_variable_get(:@client).api.instance_variable_get(:@ssl).should be_false
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'with apikey and HTTPS endpoint' do
|
33
|
-
td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey => 'test_1', :endpoint => "https://idontexi.st")
|
34
|
-
td.instance_variable_get(:@client).api.apikey.should == 'test_1'
|
35
|
-
td.instance_variable_get(:@client).api.instance_variable_get(:@host).should == "idontexi.st"
|
36
|
-
td.instance_variable_get(:@client).api.instance_variable_get(:@port).should == 443
|
37
|
-
td.instance_variable_get(:@client).api.instance_variable_get(:@ssl).should be_true
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'db config' do
|
41
|
-
td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey => 'test_1')
|
42
|
-
time = Time.now
|
43
|
-
td.should_receive(:add).with('db1', 'table1', {:foo => :bar, :time => time.to_i})
|
44
|
-
td.post_with_time('table1', {:foo => :bar}, time)
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'fluent-logger-td compat' do
|
48
|
-
td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey => 'test_2')
|
49
|
-
time = Time.now
|
50
|
-
td.should_receive(:add).with('overwrite', 'table1', {:foo => :bar, :time => time.to_i})
|
51
|
-
td.post_with_time('overwrite.table1', {:foo => :bar}, time)
|
52
|
-
end
|
53
|
-
|
54
|
-
## TODO this causes real upload
|
55
|
-
#it 'success' do
|
56
|
-
# td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey => 'test_3')
|
57
|
-
# td.post('valid', {}).should == true
|
58
|
-
#end
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'validate' do
|
62
|
-
it 'validate table name' do
|
63
|
-
td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey => 'test_4')
|
64
|
-
proc {
|
65
|
-
td.post('invalid-name', {})
|
66
|
-
}.should raise_error(RuntimeError)
|
67
|
-
proc {
|
68
|
-
td.post('', {})
|
69
|
-
}.should raise_error(RuntimeError)
|
70
|
-
proc {
|
71
|
-
td.post('9', {})
|
72
|
-
}.should raise_error(RuntimeError)
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'validate database name' do
|
76
|
-
td = TreasureData::Logger::TreasureDataLogger.new('invalid-db-name', :apikey => 'test_5')
|
77
|
-
proc {
|
78
|
-
td.post('table', {})
|
79
|
-
}.should raise_error(RuntimeError)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|