taps 0.3.11 → 0.3.12

Sign up to get free protection for your applications and to get access to all the features.
data/spec/utils_spec.rb CHANGED
@@ -2,54 +2,54 @@ require File.dirname(__FILE__) + '/base'
2
2
  require 'taps/utils'
3
3
 
4
4
  describe Taps::Utils do
5
- it "generates a checksum using crc32" do
6
- Taps::Utils.checksum("hello world").should == Zlib.crc32("hello world")
7
- end
8
-
9
- it "formats a data hash into one hash that contains an array of headers and an array of array of data" do
10
- first_row = { :x => 1, :y => 1 }
11
- first_row.stubs(:keys).returns([:x, :y])
12
- Taps::Utils.format_data([ first_row, { :x => 2, :y => 2 } ]).should == { :header => [ :x, :y ], :data => [ [1, 1], [2, 2] ] }
13
- end
14
-
15
- it "scales chunksize down slowly when the time delta of the block is just over a second" do
16
- Time.stubs(:now).returns(10.0).returns(11.5)
17
- Taps::Utils.calculate_chunksize(1000) { }.should == 900
18
- end
19
-
20
- it "scales chunksize down fast when the time delta of the block is over 3 seconds" do
21
- Time.stubs(:now).returns(10.0).returns(15.0)
22
- Taps::Utils.calculate_chunksize(3000) { }.should == 1000
23
- end
24
-
25
- it "scales up chunksize fast when the time delta of the block is under 0.8 seconds" do
26
- Time.stubs(:now).returns(10.0).returns(10.7)
27
- Taps::Utils.calculate_chunksize(1000) { }.should == 2000
28
- end
29
-
30
- it "scales up chunksize slow when the time delta of the block is between 0.8 and 1.1 seconds" do
31
- Time.stubs(:now).returns(10.0).returns(10.8)
32
- Taps::Utils.calculate_chunksize(1000) { }.should == 1100
33
-
34
- Time.stubs(:now).returns(10.0).returns(11.1)
35
- Taps::Utils.calculate_chunksize(1000) { }.should == 1100
36
- end
37
-
38
- it "will reset the chunksize to a small value if we got a broken pipe exception" do
39
- Taps::Utils.calculate_chunksize(1000) { |c| raise Errno::EPIPE if c == 1000; c.should == 10 }.should == 10
40
- end
41
-
42
- it "will reset the chunksize to a small value if we got a broken pipe exception a second time" do
43
- Taps::Utils.calculate_chunksize(1000) { |c| raise Errno::EPIPE if c == 1000 || c == 10; c.should == 1 }.should == 1
44
- end
45
-
46
- it "returns a list of columns that are text fields if the database is mysql" do
47
- @db = mock("db", :url => "mysql://localhost/mydb")
48
- @db.stubs(:schema).with(:mytable).returns([
49
- [:id, { :db_type => "int" }],
50
- [:mytext, { :db_type => "text" }]
51
- ])
52
- Taps::Utils.incorrect_blobs(@db, :mytable).should == [:mytext]
53
- end
5
+ it "generates a checksum using crc32" do
6
+ Taps::Utils.checksum("hello world").should == Zlib.crc32("hello world")
7
+ end
8
+
9
+ it "formats a data hash into one hash that contains an array of headers and an array of array of data" do
10
+ first_row = { :x => 1, :y => 1 }
11
+ first_row.stubs(:keys).returns([:x, :y])
12
+ Taps::Utils.format_data([ first_row, { :x => 2, :y => 2 } ]).should == { :header => [ :x, :y ], :data => [ [1, 1], [2, 2] ] }
13
+ end
14
+
15
+ it "scales chunksize down slowly when the time delta of the block is just over a second" do
16
+ Time.stubs(:now).returns(10.0).returns(11.5)
17
+ Taps::Utils.calculate_chunksize(1000) { }.should == 900
18
+ end
19
+
20
+ it "scales chunksize down fast when the time delta of the block is over 3 seconds" do
21
+ Time.stubs(:now).returns(10.0).returns(15.0)
22
+ Taps::Utils.calculate_chunksize(3000) { }.should == 1000
23
+ end
24
+
25
+ it "scales up chunksize fast when the time delta of the block is under 0.8 seconds" do
26
+ Time.stubs(:now).returns(10.0).returns(10.7)
27
+ Taps::Utils.calculate_chunksize(1000) { }.should == 2000
28
+ end
29
+
30
+ it "scales up chunksize slow when the time delta of the block is between 0.8 and 1.1 seconds" do
31
+ Time.stubs(:now).returns(10.0).returns(10.8)
32
+ Taps::Utils.calculate_chunksize(1000) { }.should == 1100
33
+
34
+ Time.stubs(:now).returns(10.0).returns(11.1)
35
+ Taps::Utils.calculate_chunksize(1000) { }.should == 1100
36
+ end
37
+
38
+ it "will reset the chunksize to a small value if we got a broken pipe exception" do
39
+ Taps::Utils.calculate_chunksize(1000) { |c| raise Errno::EPIPE if c == 1000; c.should == 10 }.should == 10
40
+ end
41
+
42
+ it "will reset the chunksize to a small value if we got a broken pipe exception a second time" do
43
+ Taps::Utils.calculate_chunksize(1000) { |c| raise Errno::EPIPE if c == 1000 || c == 10; c.should == 1 }.should == 1
44
+ end
45
+
46
+ it "returns a list of columns that are text fields if the database is mysql" do
47
+ @db = mock("db", :url => "mysql://localhost/mydb")
48
+ @db.stubs(:schema).with(:mytable).returns([
49
+ [:id, { :db_type => "int" }],
50
+ [:mytext, { :db_type => "text" }]
51
+ ])
52
+ Taps::Utils.incorrect_blobs(@db, :mytable).should == [:mytext]
53
+ end
54
54
  end
55
55
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 11
9
- version: 0.3.11
8
+ - 12
9
+ version: 0.3.12
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ricardo Chimal, Jr.
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-16 00:00:00 -07:00
17
+ date: 2010-09-10 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -75,9 +75,9 @@ dependencies:
75
75
  - !ruby/object:Gem::Version
76
76
  segments:
77
77
  - 3
78
- - 13
78
+ - 15
79
79
  - 0
80
- version: 3.13.0
80
+ version: 3.15.0
81
81
  type: :runtime
82
82
  version_requirements: *id004
83
83
  - !ruby/object:Gem::Dependency