Permalink
Browse files

Fixed tests for 0.8 support.

Most of the changes are from the CQL type changes in
  CASSANDRA-3149
  CASSANDRA-3031
  CASSANDRA-2883
  • Loading branch information...
1 parent 72e10df commit 56596bad0be303c097cbeca7f0f59d41c77fec1a @psanford psanford committed Dec 14, 2011
Showing with 87 additions and 63 deletions.
  1. +37 −33 spec/comparator_spec.rb
  2. +25 −15 spec/rowkey_spec.rb
  3. +25 −15 spec/validation_spec.rb
View
@@ -97,23 +97,24 @@ def test_for_value(value)
end
res.class.should eq(Time)
end
-
end
- context "with decimal comparator" do
- let(:cf_name) { "comparator_cf_decimal" }
- before(:each) { create_column_family(cf_name, 'DecimalType') }
+ if CASSANDRA_VERSION.to_f >= 1.0
+ context "with decimal comparator" do
+ let(:cf_name) { "comparator_cf_decimal" }
+ before(:each) { create_column_family(cf_name, 'DecimalType') }
- def test_for_value(value)
- create_and_fetch_column(cf_name, value).should eq(value)
- create_and_fetch_column(cf_name, value*-1).should eq(value*-1)
- end
-
- it "should return a small decimal" do
- test_for_value(15.333)
- end
- it "should return a huge decimal" do
- test_for_value(BigDecimal.new('129182739481237481341234123411.1029348102934810293481039'))
+ def test_for_value(value)
+ create_and_fetch_column(cf_name, value).should eq(value)
+ create_and_fetch_column(cf_name, value*-1).should eq(value*-1)
+ end
+
+ it "should return a small decimal" do
+ test_for_value(15.333)
+ end
+ it "should return a huge decimal" do
+ test_for_value(BigDecimal.new('129182739481237481341234123411.1029348102934810293481039'))
+ end
end
end
@@ -151,26 +152,29 @@ def test_for_value(value)
end
end
- context "with int comparator" do
- let(:cf_name) { "comparator_cf_int" }
- before(:each) { create_column_family(cf_name, 'Int32Type') }
+ if CASSANDRA_VERSION.to_f >= 1.0
+ #Int32Type was added in 1.0 (CASSANDRA-3031)
+ context "with int comparator" do
+ let(:cf_name) { "comparator_cf_int" }
+ before(:each) { create_column_family(cf_name, 'Int32Type') }
- def test_for_value(value)
- create_and_fetch_column(cf_name, value).should eq(value)
- create_and_fetch_column(cf_name, value*-1).should eq(value*-1)
- end
-
- it "should properly convert integer values that fit into 1 byte" do
- test_for_value(1)
- end
- it "should properly convert integer values that fit into 2 bytes" do
- test_for_value(2**8 + 80)
- end
- it "should properly convert integer values that fit into 3 bytes" do
- test_for_value(2**16 + 622)
- end
- it "should properly convert integer values that fit into 4 bytes" do
- test_for_value(2**24 + 45820)
+ def test_for_value(value)
+ create_and_fetch_column(cf_name, value).should eq(value)
+ create_and_fetch_column(cf_name, value*-1).should eq(value*-1)
+ end
+
+ it "should properly convert integer values that fit into 1 byte" do
+ test_for_value(1)
+ end
+ it "should properly convert integer values that fit into 2 bytes" do
+ test_for_value(2**8 + 80)
+ end
+ it "should properly convert integer values that fit into 3 bytes" do
+ test_for_value(2**16 + 622)
+ end
+ it "should properly convert integer values that fit into 4 bytes" do
+ test_for_value(2**24 + 45820)
+ end
end
end
View
@@ -56,7 +56,11 @@ def test_for_value(value)
context "with blob row_key_validation" do
let(:cf_name) { "row_key_validation_cf_blob" }
- before(:each) { create_column_family(cf_name, 'blob') }
+ if CASSANDRA_VERSION.to_f == 0.8
+ before(:each) { create_column_family(cf_name, 'bytea') }
+ else
+ before(:each) { create_column_family(cf_name, 'blob') }
+ end
it "should return a blob" do
bytes = "binary\x00"
@@ -78,20 +82,22 @@ def test_for_value(value)
end
end
- context "with decimal row_key_validation" do
- let(:cf_name) { "row_key_validation_cf_decimal" }
- before(:each) { create_column_family(cf_name, 'decimal') }
+ if CASSANDRA_VERSION.to_f >= 1.0
+ context "with decimal row_key_validation" do
+ let(:cf_name) { "row_key_validation_cf_decimal" }
+ before(:each) { create_column_family(cf_name, 'decimal') }
- def test_for_value(value)
- create_and_fetch_column(cf_name, value*-1).should eq(value*-1)
- create_and_fetch_column(cf_name, value).should eq(value)
- end
-
- it "should return a small decimal" do
- test_for_value(15.333)
- end
- it "should return a huge decimal" do
- test_for_value(BigDecimal.new('129182739481237481341234123411.1029348102934810293481039'))
+ def test_for_value(value)
+ create_and_fetch_column(cf_name, value*-1).should eq(value*-1)
+ create_and_fetch_column(cf_name, value).should eq(value)
+ end
+
+ it "should return a small decimal" do
+ test_for_value(15.333)
+ end
+ it "should return a huge decimal" do
+ test_for_value(BigDecimal.new('129182739481237481341234123411.1029348102934810293481039'))
+ end
end
end
@@ -167,7 +173,11 @@ def test_for_value(value)
context "with timestamp row_key_validation" do
let(:cf_name) { "row_key_validation_cf_timestamp" }
- before(:each) { create_column_family(cf_name, 'timestamp') }
+ if CASSANDRA_VERSION.to_f == 0.8
+ before(:each) { create_column_family(cf_name, 'date') }
+ else
+ before(:each) { create_column_family(cf_name, 'timestamp') }
+ end
it "should return a timestamp" do
uuid = UUID.new
View
@@ -56,7 +56,11 @@ def test_for_value(value)
context "with blob validation" do
let(:cf_name) { "validation_cf_blob" }
- before(:each) { create_column_family(cf_name, 'blob') }
+ if CASSANDRA_VERSION.to_f == 0.8
+ before(:each) { create_column_family(cf_name, 'bytea') }
+ else
+ before(:each) { create_column_family(cf_name, 'blob') }
+ end
it "should return a blob" do
bytes = "binary\x00"
@@ -102,20 +106,22 @@ def test_for_value(value)
end
end
- context "with decimal validation" do
- let(:cf_name) { "validation_cf_decimal" }
- before(:each) { create_column_family(cf_name, 'decimal') }
+ if CASSANDRA_VERSION.to_f >= 1.0
+ context "with decimal validation" do
+ let(:cf_name) { "validation_cf_decimal" }
+ before(:each) { create_column_family(cf_name, 'decimal') }
- def test_for_value(value)
- create_and_fetch_column(cf_name, value).should eq(value)
- create_and_fetch_column(cf_name, value*-1).should eq(value*-1)
- end
-
- it "should return a small decimal" do
- test_for_value(15.333)
- end
- it "should return a huge decimal" do
- test_for_value(BigDecimal.new('129182739481237481341234123411.1029348102934810293481039'))
+ def test_for_value(value)
+ create_and_fetch_column(cf_name, value).should eq(value)
+ create_and_fetch_column(cf_name, value*-1).should eq(value*-1)
+ end
+
+ it "should return a small decimal" do
+ test_for_value(15.333)
+ end
+ it "should return a huge decimal" do
+ test_for_value(BigDecimal.new('129182739481237481341234123411.1029348102934810293481039'))
+ end
end
end
@@ -195,7 +201,11 @@ def test_for_value(value)
context "with timestamp validation" do
let(:cf_name) { "validation_cf_timestamp" }
- before(:each) { create_column_family(cf_name, 'timestamp') }
+ if CASSANDRA_VERSION.to_f == 0.8
+ before(:each) { create_column_family(cf_name, 'date') }
+ else
+ before(:each) { create_column_family(cf_name, 'timestamp') }
+ end
it "should return a timestamp" do
ts = Time.new

0 comments on commit 56596ba

Please sign in to comment.