Sha256: 821fa3d3166e28b4b674bc8956fda0963e5292b36723747482bf876a6ddf6e27

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

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

$NITRO_NO_ENVIRONMENT = true

require 'ostruct'
require 'test/unit'

require 'glue'
require 'nitro/session'

class TC_Session < Test::Unit::TestCase # :nodoc: all
  include Nitro

  STORES = [:memory, :file, :og]

  def test_create_id
    sid = Session.new.session_id
    assert_not_equal sid, Session.new.session_id
    assert_not_equal sid, Session.new.session_id
    assert_not_equal sid, Session.new.session_id
    assert_not_equal sid, Session.new.session_id
    assert_not_equal sid, Session.new.session_id
  end

  def test_gc
    STORES.each do |store_type|
      Session.store_type = store_type
      
      if store_type == :og
        Og.setup(:store => :sqlite, :name => "/tmp/test", :destroy => true)
      end
      
      Session.keepalive = 2
      
      Session.store[1] = Session.new
      Session.store[2] = Session.new
      
      Session.store.gc!
      assert_equal 2, Session.store.all.size
      Session.store.gc!
      assert_equal 2, Session.store.all.size
      sleep(3)
      Session.store.gc!    
      assert_equal 0, Session.store.all.size
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nitro-0.26.0 test/nitro/tc_session.rb
nitro-0.27.0 test/nitro/tc_session.rb