Sha256: 82f9047194db3458253e95b3d094f24444d5c305d695a4bcc106efe979a6d020

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 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

#   CACHES = [:memory, :file, :og]
  CACHES = [:memory, :file]

  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
    CACHES.each do |cache_type|
      Session.keepalive = 2
      
      Session.cache_type = cache_type

      if cache_type == :og
        Og.setup(:store => :sqlite, :name => "/tmp/test", :destroy => true)
      end
      
      Session.cache[1] = Session.new
      Session.cache[2] = Session.new

      Session.cache.gc!
      assert_equal 2, Session.cache.all.size
      Session.cache.gc!
      assert_equal 2, Session.cache.all.size
      sleep(3)
      Session.cache.gc!    
      assert_equal 0, Session.cache.all.size
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nitro-0.28.0 test/nitro/tc_session.rb