Commit a8eb3fe1d2def9d4cc78003cd0a14de573a11fc5

Authored by Hugo Duksis
1 parent be1dc554

tests for issue #1984

Showing 1 changed file with 45 additions and 0 deletions   Show diff stats
spec/tasks/gitlab/backup_rake_spec.rb 0 → 100644
... ... @@ -0,0 +1,45 @@
  1 +require 'spec_helper'
  2 +require 'rake'
  3 +
  4 +describe 'gitlab:app namespace rake task' do
  5 + before :all do
  6 + Rake.application.rake_require "tasks/gitlab/backup"
  7 + # empty task as env is already loaded
  8 + Rake::Task.define_task :environment
  9 + end
  10 +
  11 + describe 'backup_restore' do
  12 + before do
  13 + # avoid writing task output to spec progress
  14 + $stdout.stub :write
  15 + end
  16 +
  17 + let :run_rake_task do
  18 + Rake::Task["gitlab:app:backup_restore"].reenable
  19 + Rake.application.invoke_task "gitlab:app:backup_restore"
  20 + end
  21 +
  22 + context 'gitlab version' do
  23 + before do
  24 + Dir.stub :glob => []
  25 + File.stub :exists? => true
  26 + Kernel.stub :system => true
  27 + end
  28 +
  29 + let(:gitlab_version) { %x{git rev-parse HEAD}.gsub(/\n/,"") }
  30 +
  31 + it 'should fail on mismach' do
  32 + YAML.stub :load_file => {:gitlab_version => gitlab_version.reverse}
  33 + expect { run_rake_task }.to raise_error SystemExit
  34 + end
  35 +
  36 + it 'should invoke restoration on mach' do
  37 + YAML.stub :load_file => {:gitlab_version => gitlab_version}
  38 + Rake::Task["gitlab:app:db_restore"].should_receive :invoke
  39 + Rake::Task["gitlab:app:repo_restore"].should_receive :invoke
  40 + expect { run_rake_task }.to_not raise_error SystemExit
  41 + end
  42 + end
  43 +
  44 + end # backup_restore task
  45 +end # gitlab:app namespace
... ...