Skip to content

Commit

Permalink
Fixing a few more tests where get_attributes wasn't specifying consis…
Browse files Browse the repository at this point in the history
…tent_read
  • Loading branch information
celeduc committed Jan 17, 2012
1 parent 456aca7 commit 466fded
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 46 deletions.
44 changes: 8 additions & 36 deletions failing_tests.txt
@@ -1,4 +1,4 @@
Finished tests in 552.351509s, 0.1231 tests/s, 4.1441 assertions/s. Finished tests in 552.825713s, 0.1230 tests/s, 4.1894 assertions/s.


1) Failure: 1) Failure:
test_clobs(TestLobs) [/home/ubuntu/src/simple_record/test/test_lobs.rb:45]: test_clobs(TestLobs) [/home/ubuntu/src/simple_record/test/test_lobs.rb:45]:
Expand All @@ -9,40 +9,12 @@ test_single_clob(TestLobs) [/home/ubuntu/src/simple_record/test/test_lobs.rb:87]
puts is 1, should be 0. puts is 1, should be 0.


3) Failure: 3) Failure:
test_count(TestSimpleRecord) [/home/ubuntu/src/simple_record/test/test_simple_record.rb:291]: test_count(TestSimpleRecord) [/home/ubuntu/src/simple_record/test/test_simple_record.rb:295]:
<2> expected but was Failed assertion, no message given.
<3>.


4) Failure: 4) Error:
test_dirty(TestSimpleRecord) [/home/ubuntu/src/simple_record/test/test_simple_record.rb:205]: test_storage_format(TestSimpleRecord):
<1> expected but was NoMethodError: undefined method `[]' for nil:NilClass
<0>. /home/ubuntu/src/simple_record/test/test_simple_record.rb:545:in `test_storage_format'


5) Error: 68 tests, 2316 assertions, 3 failures, 1 errors, 0 skips
test_explicit_class_name(TestSimpleRecord):
SimpleRecord::RecordNotFound: Couldn't find MyModel with ID ["088e3df4-4109-11e1-a53f-080027c736d0"]
/home/ubuntu/src/simple_record/lib/simple_record/translations.rb:93:in `eval'
/home/ubuntu/src/simple_record/lib/simple_record/active_sdb.rb:300:in `find_with_metadata'
/home/ubuntu/src/simple_record/lib/simple_record.rb:967:in `find'
(eval):1:in `sdb_to_ruby'
/home/ubuntu/src/simple_record/lib/simple_record/translations.rb:93:in `eval'
/home/ubuntu/src/simple_record/lib/simple_record/translations.rb:93:in `sdb_to_ruby'
/home/ubuntu/src/simple_record/lib/simple_record/attributes.rb:397:in `get_attribute'
/home/ubuntu/src/simple_record/lib/simple_record/attributes.rb:186:in `block in belongs_to'
/home/ubuntu/src/simple_record/test/test_simple_record.rb:531:in `test_explicit_class_name'

6) Failure:
test_nil_attr_deletion(TestSimpleRecord) [/home/ubuntu/src/simple_record/test/test_simple_record.rb:359]:
<0> expected but was
<1>.

7) Failure:
test_null(TestSimpleRecord) [/home/ubuntu/src/simple_record/test/test_simple_record.rb:384]:
<2> expected but was
<1>.

8) Failure:
test_first_validations(TestValidations) [/home/ubuntu/src/simple_record/test/test_validations.rb:51]:
#<ActiveModel::Errors:0x9c562d8 @base=#<MyModel:0x9c293b4 @errors=#<ActiveModel::Errors:0x9c562d8 ...>, @dirty={"save_count"=>nil}, @attributes={"name"=>["abcd"], "save_count"=>"09223372036854775809", "id"=>"29d80436-4109-11e1-a53f-080027c736d0", "created"=>["2012-01-17T12:45:41"], "updated"=>["2012-01-17T12:45:41"], "nickname"=>["abcd"]}, @attributes_rb={"name"=>"abcd", "created"=>Tue, 17 Jan 2012 12:45:41 +0000, "updated"=>Tue, 17 Jan 2012 12:45:41 +0000, "nickname"=>"abcd"}, @lobs={}, @new_record=false, @validation_context=nil, @attr_before_save=true, @attr_before_create=true, @attr_after_create=true, @attr_after_save=true>, @messages={:name=>["must be unique."]}>

68 tests, 2289 assertions, 7 failures, 1 errors, 0 skips
22 changes: 12 additions & 10 deletions test/test_simple_record.rb
Expand Up @@ -202,7 +202,7 @@ def test_dirty
SimpleRecord.stats.clear SimpleRecord.stats.clear
mm2.save(:dirty=>true) mm2.save(:dirty=>true)
sleep(1) #needed because mmc.my_model below does not have :consistent_read set sleep(1) #needed because mmc.my_model below does not have :consistent_read set
assert_equal SimpleRecord.stats.saves, 0 assert_equal 0, SimpleRecord.stats.saves


mmc = MyChildModel.new mmc = MyChildModel.new
mmc.my_model = mm mmc.my_model = mm
Expand Down Expand Up @@ -286,10 +286,11 @@ def test_count
assert count > 0 assert count > 0


mms = MyModel.find(:all,:consistent_read=>true) # select 2 mms = MyModel.find(:all,:consistent_read=>true) # select 2
assert mms.size > 0 # select 3 assert mms.size > 0 # still select 2
assert_equal mms.size, count assert_equal mms.size, count
assert_equal SimpleRecord.stats.selects, 3 assert_equal 2, SimpleRecord.stats.selects


sleep 1
count = MyModel.find(:count, :conditions=>["name=?", "Travis"],:consistent_read=>true) count = MyModel.find(:count, :conditions=>["name=?", "Travis"],:consistent_read=>true)
assert count > 0 assert count > 0


Expand Down Expand Up @@ -355,7 +356,7 @@ def test_nil_attr_deletion
mm.save mm.save


# Should have 1 age attribute # Should have 1 age attribute
sdb_atts = @@sdb.get_attributes('simplerecord_tests_my_models', mm.id, 'age') sdb_atts = @@sdb.get_attributes('simplerecord_tests_my_models', mm.id, 'age',true) # consistent_read
assert_equal sdb_atts[:attributes].size, 1 assert_equal sdb_atts[:attributes].size, 1


mm.age = nil mm.age = nil
Expand All @@ -365,7 +366,7 @@ def test_nil_attr_deletion
assert_equal mm.age, nil assert_equal mm.age, nil


# Should have NO age attributes # Should have NO age attributes
assert_equal @@sdb.get_attributes('simplerecord_tests_my_models', mm.id, 'age')[:attributes].size, 0 assert_equal @@sdb.get_attributes('simplerecord_tests_my_models', mm.id, 'age',true)[:attributes].size, 0
end end


def test_null def test_null
Expand All @@ -377,17 +378,17 @@ def test_null
mm2 = MyModel.new(:name=>"birthday is not null") mm2 = MyModel.new(:name=>"birthday is not null")
mm2.birthday = Time.now mm2.birthday = Time.now
mm2.save mm2.save
mms = MyModel.find(:all, :conditions=>["age is null"],:consistent_read=>true) mms = MyModel.find(:all, :conditions=>["birthday is null"],:consistent_read=>true)
mms.each do |m| mms.each do |m|
m.inspect m.inspect
end end
assert_equal mms.size, 1 assert_equal 1, mms.size
assert_equal mms[0].id, mm.id assert_equal mms[0].id, mm.id
mms = MyModel.find(:all, :conditions=>["age is not null"],:consistent_read=>true) mms = MyModel.find(:all, :conditions=>["birthday is not null"],:consistent_read=>true)
mms.each do |m| mms.each do |m|
m.inspect m.inspect
end end
assert_equal mms.size, 1 assert_equal 1, mms.size
assert_equal mms[0].id, mm2.id assert_equal mms[0].id, mm2.id
end end


Expand Down Expand Up @@ -527,6 +528,7 @@ def test_explicit_class_name
assert_equal mm2.x.id, mm.id assert_equal mm2.x.id, mm.id
mm2.save mm2.save


sleep 1 #sometimes consistent_read isn't good enough. Why? Dunno.
mm3 = MyChildModel.find(mm2.id,:consistent_read=>true) mm3 = MyChildModel.find(mm2.id,:consistent_read=>true)
assert_equal mm3.x.id, mm.id assert_equal mm3.x.id, mm.id
end end
Expand All @@ -538,7 +540,7 @@ def test_storage_format
mm.date2 = DateTime.now mm.date2 = DateTime.now
mm.save mm.save


raw = @@sdb.get_attributes(MyModel.domain, mm.id) raw = @@sdb.get_attributes(MyModel.domain, mm.id, nil, true)
puts raw.inspect #observation interferes with this in some way puts raw.inspect #observation interferes with this in some way
assert_equal raw[:attributes]["updated"][0].size, "2010-01-06T16:04:23".size assert_equal raw[:attributes]["updated"][0].size, "2010-01-06T16:04:23".size
assert_equal raw[:attributes]["date1"][0].size, "2010-01-06T16:04:23".size assert_equal raw[:attributes]["date1"][0].size, "2010-01-06T16:04:23".size
Expand Down

0 comments on commit 466fded

Please sign in to comment.