class TestSiteBackup

Public Instance Methods

setup() click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 218
def setup
  site = MockSite.new
  config = MockConfig.new
  @backup = Qwik::SiteBackup.new(site, config)
end
test_archive_path() click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 224
def test_archive_path
  expected = ".test/data/test/.cache/test.tgz".path
  actual = @backup.archive_path
  is expected, actual
end
test_backup_is_creating() click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 276
def test_backup_is_creating
  site_lastmod = Time.at(0)
  archive_mtime = Time.at(0)
  tmpfile_mtime = Time.at(1)
  excepted = true
  actual = @backup.generating?(site_lastmod, archive_mtime, tmpfile_mtime)
  is excepted, actual
end
test_backup_is_creating2() click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 285
def test_backup_is_creating2
  site_lastmod = Time.at(0)
  archive_mtime = nil
  tmpfile_mtime = Time.at(1)
  excepted = true
  actual = @backup.generating?(site_lastmod, archive_mtime, tmpfile_mtime)
  is excepted, actual, "at first: backup is not exist"
end
test_backup_is_creating3() click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 294
def test_backup_is_creating3
  site_lastmod = Time.at(0)
  archive_mtime = Time.at(1)
  tmpfile_mtime = Time.at(1)
  excepted = true
  actual = @backup.generating?(site_lastmod, archive_mtime, tmpfile_mtime)
  is excepted, actual, "tmp and backup is same"
end
test_backup_is_latest() click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 240
def test_backup_is_latest
  site_lastmod = Time.at(0)
  archive_mtime = Time.at(1)
  tmpfile_mtime = nil
  excepted = true
  actual = @backup.latest?(site_lastmod, archive_mtime, tmpfile_mtime)
  is excepted, actual
end
test_backup_is_latest2() click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 249
def test_backup_is_latest2
  site_lastmod = Time.at(0)
  archive_mtime = Time.at(0)
  tmpfile_mtime = nil
  excepted = true
  actual = @backup.latest?(site_lastmod, archive_mtime, tmpfile_mtime)
  is excepted, actual, "archive and site-lastmod is same"
end
test_backup_is_not_creating() click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 303
def test_backup_is_not_creating
  site_lastmod = Time.at(0)
  archive_mtime = Time.at(0)
  tmpfile_mtime = nil
  excepted = false
  actual = @backup.generating?(site_lastmod, archive_mtime, tmpfile_mtime)
  is excepted, actual, "tmp is absent"
end
test_backup_is_not_creating2() click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 312
def test_backup_is_not_creating2
  site_lastmod = Time.at(1)
  archive_mtime = Time.at(1)
  tmpfile_mtime = Time.at(1)
  excepted = false
  actual = @backup.generating?(site_lastmod, archive_mtime, tmpfile_mtime)
  is excepted, actual, "site is modified"
end
test_backup_is_not_latest2() click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 258
def test_backup_is_not_latest2
  site_lastmod = Time.at(0)
  archive_mtime = Time.at(1)
  tmpfile_mtime = Time.at(1)
  excepted = false
  actual = @backup.latest?(site_lastmod, archive_mtime, tmpfile_mtime)
  is excepted, actual, "tmpfile is latest"
end
test_backup_is_not_latest3() click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 267
def test_backup_is_not_latest3
  site_lastmod = Time.at(0)
  archive_mtime = nil
  tmpfile_mtime = nil
  excepted = false
  actual = @backup.latest?(site_lastmod, archive_mtime, tmpfile_mtime)
  is excepted, actual, "backup is not exist"
end
test_command() click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 342
def test_command
  expected = "#{Qwik::SiteBackup::TAR_CMD} zcf .test/data/test/.cache/sitebackup.tmp -C .test/data/ " +
    "--exclude .cache --exclude .svn -h test"
  actual = @backup.command
  is expected, actual
end
test_command_exist() click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 236
def test_command_exist
  ok Qwik::SiteBackup.command_exist?
end
test_do_concurrent() click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 349
def test_do_concurrent
  t1 = t2 = nil
  thread = @backup.do_concurrent {
    Thread.pass
    sleep 0.1
    t1 = Time.now
  }
  t2 = Time.now
  thread.join
  assert_not_equal t1.to_f, t2.to_f
end
test_invoke() click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 321
def test_invoke
  expected = :success
  input = "ruby -e 'true'"
  actual = @backup.invoke(input)
  is expected, actual
end
test_invoke_fail() click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 328
def test_invoke_fail
  expected = :failure
  input = "ruby -e 'exit 1'"
  actual = @backup.invoke(input)
  is expected, actual, "exit status sould be 1"
end
test_invoke_unavailable() click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 335
def test_invoke_unavailable
  expected = :failure
  input = "never-seen-command"
  actual = @backup.invoke(input)
  is expected, actual, "command should not found"
end
test_tmpfile_path() click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 230
def test_tmpfile_path
  expected = ".test/data/test/.cache/sitebackup.tmp".path
  actual = @backup.tmpfile_path
  is expected, actual
end