td-logger 0.3.24 → 0.3.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
-