Skip to content

Commit

Permalink
Fixed tests for 0.8 support.
Browse files Browse the repository at this point in the history
Most of the changes are from the CQL type changes in
  CASSANDRA-3149
  CASSANDRA-3031
  CASSANDRA-2883
  • Loading branch information
Peter Sanford committed Dec 14, 2011
1 parent 72e10df commit 56596ba
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 63 deletions.
70 changes: 37 additions & 33 deletions spec/comparator_spec.rb
Expand Up @@ -97,23 +97,24 @@ def test_for_value(value)
end end
res.class.should eq(Time) res.class.should eq(Time)
end end

end end


context "with decimal comparator" do if CASSANDRA_VERSION.to_f >= 1.0
let(:cf_name) { "comparator_cf_decimal" } context "with decimal comparator" do
before(:each) { create_column_family(cf_name, 'DecimalType') } let(:cf_name) { "comparator_cf_decimal" }
before(:each) { create_column_family(cf_name, 'DecimalType') }


def test_for_value(value) def test_for_value(value)
create_and_fetch_column(cf_name, value).should eq(value) create_and_fetch_column(cf_name, value).should eq(value)
create_and_fetch_column(cf_name, value*-1).should eq(value*-1) create_and_fetch_column(cf_name, value*-1).should eq(value*-1)
end end


it "should return a small decimal" do it "should return a small decimal" do
test_for_value(15.333) test_for_value(15.333)
end end
it "should return a huge decimal" do it "should return a huge decimal" do
test_for_value(BigDecimal.new('129182739481237481341234123411.1029348102934810293481039')) test_for_value(BigDecimal.new('129182739481237481341234123411.1029348102934810293481039'))
end
end end
end end


Expand Down Expand Up @@ -151,26 +152,29 @@ def test_for_value(value)
end end
end end


context "with int comparator" do if CASSANDRA_VERSION.to_f >= 1.0
let(:cf_name) { "comparator_cf_int" } #Int32Type was added in 1.0 (CASSANDRA-3031)
before(:each) { create_column_family(cf_name, 'Int32Type') } context "with int comparator" do
let(:cf_name) { "comparator_cf_int" }
before(:each) { create_column_family(cf_name, 'Int32Type') }


def test_for_value(value) def test_for_value(value)
create_and_fetch_column(cf_name, value).should eq(value) create_and_fetch_column(cf_name, value).should eq(value)
create_and_fetch_column(cf_name, value*-1).should eq(value*-1) create_and_fetch_column(cf_name, value*-1).should eq(value*-1)
end end


it "should properly convert integer values that fit into 1 byte" do it "should properly convert integer values that fit into 1 byte" do
test_for_value(1) test_for_value(1)
end end
it "should properly convert integer values that fit into 2 bytes" do it "should properly convert integer values that fit into 2 bytes" do
test_for_value(2**8 + 80) test_for_value(2**8 + 80)
end end
it "should properly convert integer values that fit into 3 bytes" do it "should properly convert integer values that fit into 3 bytes" do
test_for_value(2**16 + 622) test_for_value(2**16 + 622)
end end
it "should properly convert integer values that fit into 4 bytes" do it "should properly convert integer values that fit into 4 bytes" do
test_for_value(2**24 + 45820) test_for_value(2**24 + 45820)
end
end end
end end


Expand Down
40 changes: 25 additions & 15 deletions spec/rowkey_spec.rb
Expand Up @@ -56,7 +56,11 @@ def test_for_value(value)


context "with blob row_key_validation" do context "with blob row_key_validation" do
let(:cf_name) { "row_key_validation_cf_blob" } 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 it "should return a blob" do
bytes = "binary\x00" bytes = "binary\x00"
Expand All @@ -78,20 +82,22 @@ def test_for_value(value)
end end
end end


context "with decimal row_key_validation" do if CASSANDRA_VERSION.to_f >= 1.0
let(:cf_name) { "row_key_validation_cf_decimal" } context "with decimal row_key_validation" do
before(:each) { create_column_family(cf_name, 'decimal') } let(:cf_name) { "row_key_validation_cf_decimal" }
before(:each) { create_column_family(cf_name, 'decimal') }


def test_for_value(value) def test_for_value(value)
create_and_fetch_column(cf_name, value*-1).should eq(value*-1) create_and_fetch_column(cf_name, value*-1).should eq(value*-1)
create_and_fetch_column(cf_name, value).should eq(value) create_and_fetch_column(cf_name, value).should eq(value)
end end


it "should return a small decimal" do it "should return a small decimal" do
test_for_value(15.333) test_for_value(15.333)
end end
it "should return a huge decimal" do it "should return a huge decimal" do
test_for_value(BigDecimal.new('129182739481237481341234123411.1029348102934810293481039')) test_for_value(BigDecimal.new('129182739481237481341234123411.1029348102934810293481039'))
end
end end
end end


Expand Down Expand Up @@ -167,7 +173,11 @@ def test_for_value(value)


context "with timestamp row_key_validation" do context "with timestamp row_key_validation" do
let(:cf_name) { "row_key_validation_cf_timestamp" } 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 it "should return a timestamp" do
uuid = UUID.new uuid = UUID.new
Expand Down
40 changes: 25 additions & 15 deletions spec/validation_spec.rb
Expand Up @@ -56,7 +56,11 @@ def test_for_value(value)


context "with blob validation" do context "with blob validation" do
let(:cf_name) { "validation_cf_blob" } 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 it "should return a blob" do
bytes = "binary\x00" bytes = "binary\x00"
Expand Down Expand Up @@ -102,20 +106,22 @@ def test_for_value(value)
end end
end end


context "with decimal validation" do if CASSANDRA_VERSION.to_f >= 1.0
let(:cf_name) { "validation_cf_decimal" } context "with decimal validation" do
before(:each) { create_column_family(cf_name, 'decimal') } let(:cf_name) { "validation_cf_decimal" }
before(:each) { create_column_family(cf_name, 'decimal') }


def test_for_value(value) def test_for_value(value)
create_and_fetch_column(cf_name, value).should eq(value) create_and_fetch_column(cf_name, value).should eq(value)
create_and_fetch_column(cf_name, value*-1).should eq(value*-1) create_and_fetch_column(cf_name, value*-1).should eq(value*-1)
end end


it "should return a small decimal" do it "should return a small decimal" do
test_for_value(15.333) test_for_value(15.333)
end end
it "should return a huge decimal" do it "should return a huge decimal" do
test_for_value(BigDecimal.new('129182739481237481341234123411.1029348102934810293481039')) test_for_value(BigDecimal.new('129182739481237481341234123411.1029348102934810293481039'))
end
end end
end end


Expand Down Expand Up @@ -195,7 +201,11 @@ def test_for_value(value)


context "with timestamp validation" do context "with timestamp validation" do
let(:cf_name) { "validation_cf_timestamp" } 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 it "should return a timestamp" do
ts = Time.new ts = Time.new
Expand Down

0 comments on commit 56596ba

Please sign in to comment.