Sha256: d115a1afa4326c494312cb2eec6fdd582e34b4b9e75f776a79bcca22420ed7e9

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

require File.join(File.dirname(__FILE__), '..', 'CONFIG.rb')
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.metadata
    # p Article.metadata

    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

3 entries across 3 versions & 1 rubygems

Version Path
og-0.24.0 test/og/store/tc_filesys.rb
og-0.25.0 test/og/store/tc_filesys.rb
og-0.26.0 test/og/store/tc_filesys.rb