class TestBackupDB

Public Instance Methods

setup() click to toggle source
# File vendor/qwik/lib/qwik/db-backup.rb, line 93
def setup
  config = Qwik::Config.new
  config.update Qwik::Config::DebugConfig
  config.update Qwik::Config::TestConfig
  @path = '.test/'.path
  @path.setup

  spath = config.super_dir.path
  @pagedb = Qwik::FileSystemDB.new(@path, spath)

  # test_initialize
  backupdb = Qwik::BackupDB.new(@path)
  @pagedb.register_observer(backupdb)
end
teardown() click to toggle source
# File vendor/qwik/lib/qwik/db-backup.rb, line 180
def teardown
  @path.teardown
end
test_backupdb() click to toggle source
# File vendor/qwik/lib/qwik/db-backup.rb, line 108
    def test_backupdb
      # test_put
      @pagedb.create('1')
      @pagedb.put('1', 't', 1)

      budb = @pagedb.backupdb
      assert_instance_of(Qwik::BackupDB, budb)

      # test_each_by_key
      budb.each_by_key('1') {|v, time|
        assert_instance_of(String, v)
        assert_instance_of(Time, time)
        s = budb.get('1', time)
        assert_instance_of(String, s)
#       eq v, s
      }

      # FIXME: test_put, test_exist should be exist.
    end
test_ignore_pages() click to toggle source
# File vendor/qwik/lib/qwik/db-backup.rb, line 128
def test_ignore_pages
  key = '_SiteLog'
  @pagedb.create(key)
  @pagedb.put(key, 't', 1)

  # test_each_by_key
  found = false
  @pagedb.backupdb.each_by_key(key) {|v, time|
    found = true
  }
  assert_equal false, found
end
test_ignore_pages2() click to toggle source
# File vendor/qwik/lib/qwik/db-backup.rb, line 141
def test_ignore_pages2
  key = '_counter_1'
  @pagedb.create(key)
  @pagedb.put(key, 't', 1)

  # test_each_by_key
  found = false
  @pagedb.backupdb.each_by_key(key) {|v, time|
    found = true
  }
  assert_equal false, found
end
test_ignore_pages3() click to toggle source
# File vendor/qwik/lib/qwik/db-backup.rb, line 154
def test_ignore_pages3
  key = '_counter_'
  @pagedb.create(key)
  @pagedb.put(key, 't', 1)

  # test_each_by_key
  found = false
  @pagedb.backupdb.each_by_key(key) {|v, time|
    found = true
  }
  assert_equal true, found
end
test_ignore_pages4() click to toggle source
# File vendor/qwik/lib/qwik/db-backup.rb, line 167
def test_ignore_pages4
  key = '_SiteLogHoge'
  @pagedb.create(key)
  @pagedb.put(key, 't', 1)

  # test_each_by_key
  found = false
  @pagedb.backupdb.each_by_key(key) {|v, time|
    found = true
  }
  assert_equal true, found
end