Sha256: b38356620775a38d0a79dd69b099f2345b6cbd18857912780f80f5a9cc75718b

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

$:.unshift File.join(File.dirname(__FILE__), 'lib')

require 'test/unit'

require 'og'

class TestCaseOgFilesys < Test::Unit::TestCase # :nodoc: all
  include Og

  class Comment; end

  class Article
    property :body, String
    has_many :comment, Comment

    def initialize(body = nil)
      @body = body
    end
  end

  class Comment
    property :body, String
    belongs_to :article, Article

    def initialize(body = nil)
      @body = body
    end
  end

  class User
    property :name, :name_key => true
  end
  
  def setup
    @og = Og.setup(:store => 'filesys', :name => 'test')
  end

  def teardown
    @og = nil
  end

  def test_all
    # p Comment.__meta
    # p Article.__meta

    a1 = Article.new('Article 1')
    @og.store.save(a1)  

    a2 = @og.store.load(1, Article)

    assert_equal a1.body, a2.body

    a3 = Article.new('Article 3')
    a3.save  
  
    @og.store.delete(a3)

    assert @og.store.load(1, Article)
    assert !@og.store.load(2, Article)

    a2.delete

    # a.comments << Comment.new('Comment 1')
    # a.save
    # a = Article[1]

    @og.store.close
    @og.store.class.destroy(@og.options)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
og-0.21.0 test/og/store/tc_filesys.rb
og-0.21.2 test/og/store/tc_filesys.rb