Add beaker tests for git create
authorJohn Duarte <john.duarte@puppetlabs.com>
Sat, 10 May 2014 16:36:26 +0000 (09:36 -0700)
committerJohn Duarte <john.duarte@puppetlabs.com>
Sun, 18 May 2014 18:38:19 +0000 (11:38 -0700)
spec/acceptance/beaker/create/create_bare_repo_that_already_exists.rb [new file with mode: 0644]
spec/acceptance/beaker/create/create_repo_that_already_exists.rb [new file with mode: 0644]
spec/acceptance/beaker/create/negative/create_bare_repo_specifying_revision.rb [new file with mode: 0644]

diff --git a/spec/acceptance/beaker/create/create_bare_repo_that_already_exists.rb b/spec/acceptance/beaker/create/create_bare_repo_that_already_exists.rb
new file mode 100644 (file)
index 0000000..663c758
--- /dev/null
@@ -0,0 +1,35 @@
+test_name 'C3472 - create bare repo that already exists'
+
+# Globals
+repo_name = 'testrepo_bare_repo_already_exists.git'
+
+hosts.each do |host|
+  tmpdir = host.tmpdir('vcsrepo')
+  step 'setup - create bare repo' do
+    install_package(host, 'git')
+    on(host, "mkdir #{tmpdir}/#{repo_name}")
+    on(host, "cd #{tmpdir}/#{repo_name} && git --bare init")
+  end
+
+  teardown do
+    on(host, "rm -fr #{tmpdir}")
+  end
+
+  step 'create bare repo that already exists using puppet' do
+    pp = <<-EOS
+    vcsrepo { "#{tmpdir}/#{repo_name}":
+      ensure => bare,
+      provider => git,
+    }
+    EOS
+
+    apply_manifest_on(host, pp)
+  end
+
+  step 'verify repo does not contain .git directory' do
+    on(host, "ls -al #{tmpdir}/#{repo_name}") do |res|
+      fail_test "found .git for #{repo_name}" if res.stdout.include? ".git"
+    end
+  end
+
+end
diff --git a/spec/acceptance/beaker/create/create_repo_that_already_exists.rb b/spec/acceptance/beaker/create/create_repo_that_already_exists.rb
new file mode 100644 (file)
index 0000000..7c28998
--- /dev/null
@@ -0,0 +1,37 @@
+test_name 'C3470 - create repo that already exists'
+
+# Globals
+repo_name = 'testrepo_already_exists'
+
+hosts.each do |host|
+  tmpdir = host.tmpdir('vcsrepo')
+  step 'setup - create repo' do
+    install_package(host, 'git')
+    my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..'))
+    scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
+    on(host, "cd #{tmpdir} && ./create_git_repo.sh")
+    on(host, "cd #{tmpdir} && git clone file://#{tmpdir}/testrepo.git #{repo_name}")
+  end
+
+  teardown do
+    on(host, "rm -fr #{tmpdir}")
+  end
+
+  step 'create repo that already exists using puppet' do
+    pp = <<-EOS
+    vcsrepo { "#{tmpdir}/#{repo_name}":
+      ensure => present,
+      provider => git,
+    }
+    EOS
+
+    apply_manifest_on(host, pp)
+  end
+
+  step 'verify repo is on master branch' do
+    on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
+      assert_match(/ref: refs\/heads\/master/, stdout, "Git checkout not on master on #{host}")
+    end
+  end
+
+end
diff --git a/spec/acceptance/beaker/create/negative/create_bare_repo_specifying_revision.rb b/spec/acceptance/beaker/create/negative/create_bare_repo_specifying_revision.rb
new file mode 100644 (file)
index 0000000..6a12c8c
--- /dev/null
@@ -0,0 +1,34 @@
+test_name 'C3473 - create bare repo specifying revision'
+
+# Globals
+repo_name = 'testrepo_bare.git'
+
+hosts.each do |host|
+  tmpdir = host.tmpdir('vcsrepo')
+  step 'setup' do
+    install_package(host, 'git')
+  end
+
+  teardown do
+    on(host, "rm -fr #{tmpdir}")
+  end
+
+  step 'create bare repo specifying revision using puppet' do
+    pp = <<-EOS
+    vcsrepo { "#{tmpdir}/#{repo_name}":
+      ensure => bare,
+      revision => master,
+      provider => git,
+    }
+    EOS
+
+    apply_manifest_on(host, pp, :acceptable_exit_codes => [1])
+  end
+
+  step 'verify repo was NOT created' do
+    on(host, "ls -al #{tmpdir}") do |res|
+      fail_test "found #{repo_name}" if res.stdout.include? "#{repo_name}"
+    end
+  end
+
+end