From 1ebe52ef9963391f13b406c843c8f475668f173c Mon Sep 17 00:00:00 2001 From: Phil Pham Date: Fri, 14 Feb 2014 11:16:15 -0800 Subject: add beaker-rspec support This adds support for beaker-rspec as well as basic test coverage for git --- spec/acceptance/clone_repo_spec.rb | 443 +++++++++++++++++++++++++++++++++++++ 1 file changed, 443 insertions(+) create mode 100644 spec/acceptance/clone_repo_spec.rb (limited to 'spec/acceptance/clone_repo_spec.rb') diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb new file mode 100644 index 0000000..4e2db19 --- /dev/null +++ b/spec/acceptance/clone_repo_spec.rb @@ -0,0 +1,443 @@ +require 'spec_helper_acceptance' + +tmpdir = default.tmpdir('vcsrepo') + +describe 'clones a remote repo' do + before(:all) do + my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + shell("mkdir -p #{tmpdir}") # win test + scp_to(default, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + shell("cd #{tmpdir} && ./create_git_repo.sh") + end + + after(:all) do + shell("rm -rf #{tmpdir}/testrepo.git") + end + + context 'get the current master HEAD' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo/.git") do + it { should be_directory } + end + + describe file("#{tmpdir}/testrepo/.git/HEAD") do + it { should contain 'ref: refs/heads/master' } + end + end + + context 'using a commit SHA' do + let (:sha) do + shell("git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1").stdout.chomp + end + + after(:all) do + shell("rm -rf #{tmpdir}/testrepo_sha") + end + + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_sha": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + revision => "#{sha}", + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_sha/.git") do + it { should be_directory } + end + + describe file("#{tmpdir}/testrepo_sha/.git/HEAD") do + it { should contain sha } + end + end + + context 'using a tag' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_tag": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + revision => '0.0.2', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_tag/.git") do + it { should be_directory } + end + + it 'should have the tag as the HEAD' do + shell("git --git-dir=#{tmpdir}/testrepo_tag/.git name-rev HEAD | grep '0.0.2'") + end + end + + context 'using a branch name' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_branch": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + revision => 'a_branch', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_branch/.git") do + it { should be_directory } + end + + describe file("#{tmpdir}/testrepo_branch/.git/HEAD") do + it { should contain 'ref: refs/heads/a_branch' } + end + end + + context 'ensure latest' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_latest": + ensure => latest, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + revision => 'master', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + it 'verifies the HEAD commit SHA on remote and local match' do + remote_commit = shell("git ls-remote file://#{tmpdir}/testrepo_latest HEAD | head -1").stdout + local_commit = shell("git --git-dir=#{tmpdir}/testrepo_latest/.git rev-parse HEAD").stdout.chomp + expect(remote_commit).to include(local_commit) + end + end + + context 'with shallow clone' do + it 'does a shallow clone' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_shallow": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + depth => '1', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_shallow/.git/shallow") do + it { should be_file } + end + end + + context 'path is not empty and not a repository' do + before(:all) do + shell("mkdir #{tmpdir}/not_a_repo", :acceptable_exit_codes => [0,1]) + shell("touch #{tmpdir}/not_a_repo/file1.txt", :acceptable_exit_codes => [0,1]) + end + + it 'should raise an exception' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/not_a_repo": + ensure => present, + provider => git + source => "file://#{tmpdir}/testrepo.git", + } + EOS + apply_manifest(pp, :expect_failures => true) + end + end + + context 'with an owner' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_owner": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + owner => 'vagrant', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_owner") do + it { should be_directory } + it { should be_owned_by 'vagrant' } + end + end + + context 'with a group' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "/#{tmpdir}/testrepo_group": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + group => 'vagrant', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_group") do + it { should be_directory } + it { should be_grouped_into 'vagrant' } + end + end + + context 'with excludes' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_excludes": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + excludes => ['exclude1.txt', 'exclude2.txt'], + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_excludes/.git/info/exclude") do + its(:content) { should match /exclude1.txt/ } + its(:content) { should match /exclude2.txt/ } + end + end + + context 'with force' do + before(:all) do + shell("mkdir -p #{tmpdir}/testrepo_force/folder") + shell("touch #{tmpdir}/testrepo_force/temp.txt") + end + + it 'applies the manifest' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_force": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + force => true, + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_force/folder") do + it { should_not be_directory } + end + + describe file("#{tmpdir}/testrepo_force/temp.txt") do + it { should_not be_file } + end + + describe file("#{tmpdir}/testrepo_force/.git") do + it { should be_directory } + end + end + + context 'as a user' do + before(:all) do + shell("chmod 707 #{tmpdir}") + pp = <<-EOS + user { 'testuser': + ensure => present, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'applies the manifest' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_user": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + user => 'testuser', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/testrepo_user") do + it { should be_directory } + it { should be_owned_by 'testuser' } + end + + describe file("#{tmpdir}/testrepo_user") do + it { should be_directory } + it { should be_grouped_into 'testuser' } + end + end + + context 'non-origin remote name' do + it 'applies the manifest' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_remote": + ensure => present, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + remote => 'testorigin', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + it 'remote name is "testorigin"' do + shell("git --git-dir=#{tmpdir}/testrepo_remote/.git remote | grep 'testorigin'") + end + + after(:all) do + pp = 'user { "testuser": ensure => absent }' + apply_manifest(pp, :catch_failures => true) + end + end + + context 'as a user with ssh' do + before(:all) do + # create user + pp = <<-EOS + user { 'testuser-ssh': + ensure => present, + managehome => true, + } + EOS + apply_manifest(pp, :catch_failures => true) + + # create ssh keys + shell('mkdir -p /home/testuser-ssh/.ssh') + shell('ssh-keygen -q -t rsa -f /home/testuser-ssh/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + shell('cat /home/testuser-ssh/.ssh/id_rsa.pub > /home/testuser-ssh/.ssh/authorized_keys') + shell('echo -e "Host localhost\n\tStrictHostKeyChecking no\n" > /home/testuser-ssh/.ssh/config') + shell('chown -R testuser-ssh:testuser-ssh /home/testuser-ssh/.ssh') + end + + it 'applies the manifest' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_user_ssh": + ensure => present, + provider => git, + source => "testuser-ssh@localhost:#{tmpdir}/testrepo.git", + user => 'testuser-ssh', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + after(:all) do + pp = <<-EOS + user { 'testuser-ssh': + ensure => absent, + managehome => true, + } + EOS + apply_manifest(pp, :catch_failures => true) + end + end + + context 'using an identity file' do + before(:all) do + # create user + pp = <<-EOS + user { 'testuser-ssh': + ensure => present, + managehome => true, + } + EOS + apply_manifest(pp, :catch_failures => true) + + # create ssh keys + shell('mkdir -p /home/testuser-ssh/.ssh') + shell('ssh-keygen -q -t rsa -f /home/testuser-ssh/.ssh/id_rsa -N ""') + + # copy public key to authorized_keys + shell('cat /home/testuser-ssh/.ssh/id_rsa.pub > /home/testuser-ssh/.ssh/authorized_keys') + shell('echo -e "Host localhost\n\tStrictHostKeyChecking no\n" > /home/testuser-ssh/.ssh/config') + shell('chown -R testuser-ssh:testuser-ssh /home/testuser-ssh/.ssh') + end + + it 'applies the manifest' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_user_ssh_id": + ensure => present, + provider => git, + source => "testuser-ssh@localhost:#{tmpdir}/testrepo.git", + identity => '/home/testuser-ssh/.ssh/id_rsa', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + after(:all) do + pp = <<-EOS + user { 'testuser-ssh': + ensure => absent, + managehome => true, + } + EOS + apply_manifest(pp, :catch_failures => true) + end + end +end -- cgit v1.2.3 From 35ba3c859c83df6c725579986b8681d3aaa3813f Mon Sep 17 00:00:00 2001 From: John Duarte Date: Mon, 12 May 2014 14:58:35 -0700 Subject: Add test for ensure latest with branch specified --- spec/acceptance/clone_repo_spec.rb | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'spec/acceptance/clone_repo_spec.rb') diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index 4e2db19..3ebbcfa 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -121,14 +121,36 @@ describe 'clones a remote repo' do end end - context 'ensure latest' do + context 'ensure latest with branch specified' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/testrepo_latest": + ensure => latest, + provider => git, + source => "file://#{tmpdir}/testrepo.git", + revision => 'a_branch', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + it 'verifies the HEAD commit SHA on remote and local match' do + remote_commit = shell("git ls-remote file://#{tmpdir}/testrepo_latest HEAD | head -1").stdout + local_commit = shell("git --git-dir=#{tmpdir}/testrepo_latest/.git rev-parse HEAD").stdout.chomp + expect(remote_commit).to include(local_commit) + end + end + + context 'ensure latest with branch unspecified' do it 'clones a repo' do pp = <<-EOS vcsrepo { "#{tmpdir}/testrepo_latest": ensure => latest, provider => git, source => "file://#{tmpdir}/testrepo.git", - revision => 'master', } EOS -- cgit v1.2.3 From 9a8e5680a5bd9179e227a13e9732721178d3ddf2 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Mon, 5 May 2014 13:49:51 -0700 Subject: Ensure vagrant user/group for non-vagrant testing These tests assert the vagrant user and group. When testing on non-vagrant systems these tests will fail. Ensure that the user/group are present in order to allow the tests to pass on other systems. --- spec/acceptance/clone_repo_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'spec/acceptance/clone_repo_spec.rb') diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index 4e2db19..1797c64 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -184,6 +184,13 @@ describe 'clones a remote repo' do end context 'with an owner' do + pp = <<-EOS + user { 'vagrant': + ensure => present, + } + EOS + + apply_manifest(pp, :catch_failures => true) it 'clones a repo' do pp = <<-EOS vcsrepo { "#{tmpdir}/testrepo_owner": @@ -206,6 +213,14 @@ describe 'clones a remote repo' do end context 'with a group' do + pp = <<-EOS + group { 'vagrant': + ensure => present, + } + EOS + + apply_manifest(pp, :catch_failures => true) + it 'clones a repo' do pp = <<-EOS vcsrepo { "/#{tmpdir}/testrepo_group": -- cgit v1.2.3 From 508373904f746242f5ac9a8132269c25081f26fc Mon Sep 17 00:00:00 2001 From: John Duarte Date: Sun, 15 Jun 2014 10:57:25 -0700 Subject: Define group in clone_repo_spec test A matching group is not added for a user when added on SLES 11. This commit adds a group to the setup manifests in order to ensure that the proper group is added to the system during the test preparation. --- spec/acceptance/clone_repo_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'spec/acceptance/clone_repo_spec.rb') diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index e76f4bc..a989661 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -324,8 +324,12 @@ describe 'clones a remote repo' do before(:all) do shell("chmod 707 #{tmpdir}") pp = <<-EOS + group { 'testuser': + ensure => present, + } user { 'testuser': ensure => present, + groups => 'testuser', } EOS @@ -388,8 +392,12 @@ describe 'clones a remote repo' do before(:all) do # create user pp = <<-EOS + group { 'testuser-ssh': + ensure => present, + } user { 'testuser-ssh': ensure => present, + groups => 'testuser-ssh', managehome => true, } EOS -- cgit v1.2.3 From 818f5298b6be3b1a25e997ba84eae237d9051be9 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 20 Jun 2014 13:48:02 -0700 Subject: Update noop to work --- spec/acceptance/clone_repo_spec.rb | 40 ++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'spec/acceptance/clone_repo_spec.rb') diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index a989661..23b0b31 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -318,6 +318,36 @@ describe 'clones a remote repo' do describe file("#{tmpdir}/testrepo_force/.git") do it { should be_directory } end + + context 'and noop' do + let(:repo_name) do + 'testrepo_already_exists' + end + before(:all) do + shell("mkdir #{tmpdir}/#{repo_name}") + shell("cd #{tmpdir}/#{repo_name} && git init") + shell("cd #{tmpdir}/#{repo_name} && touch a && git add a && git commit -m 'a'") + end + after(:all) do + shell("rm -rf #{tmpdir}/#{repo_name}") + end + + it 'applies the manifest' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + source => "file://#{tmpdir}/testrepo.git", + provider => git, + force => true, + noop => true, + } + EOS + + apply_manifest_on(host, pp, :catch_changes => true) do |r| + expect(r.stdout).to match(/Noop Mode/) + end + end + end end context 'as a user' do @@ -474,15 +504,5 @@ describe 'clones a remote repo' do apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end - - after(:all) do - pp = <<-EOS - user { 'testuser-ssh': - ensure => absent, - managehome => true, - } - EOS - apply_manifest(pp, :catch_failures => true) - end end end -- cgit v1.2.3 From cefcee8dd6e87a61301b7af267eb524b45700afd Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 27 Jun 2014 12:40:33 -0700 Subject: Patch misuse of apply_manifest_on --- spec/acceptance/clone_repo_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/acceptance/clone_repo_spec.rb') diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index 23b0b31..c52a5d2 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -343,7 +343,7 @@ describe 'clones a remote repo' do } EOS - apply_manifest_on(host, pp, :catch_changes => true) do |r| + apply_manifest(pp, :catch_changes => true) do |r| expect(r.stdout).to match(/Noop Mode/) end end -- cgit v1.2.3 From 1df5570580c1d429a8fed25033a19333fcaffbda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Mon, 29 Sep 2014 19:19:21 +0200 Subject: Convert specs to RSpec 2.99.2 syntax with Transpec This conversion is done by Transpec 2.3.7 with the following command: transpec * 22 conversions from: it { should ... } to: it { is_expected.to ... } * 19 conversions from: obj.should to: expect(obj).to * 15 conversions from: == expected to: eq(expected) * 5 conversions from: it { should_not ... } to: it { is_expected.not_to ... } * 2 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 2 conversions from: obj.should_not to: expect(obj).not_to * 2 conversions from: proc { }.should to: expect { }.to * 1 conversion from: be_false to: be_falsey * 1 conversion from: be_true to: be_truthy For more details: https://github.com/yujinakayama/transpec#supported-conversions --- spec/acceptance/clone_repo_spec.rb | 49 ++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'spec/acceptance/clone_repo_spec.rb') diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index c52a5d2..f3e77db 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -30,11 +30,11 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo/.git") do - it { should be_directory } + it { is_expected.to be_directory } end describe file("#{tmpdir}/testrepo/.git/HEAD") do - it { should contain 'ref: refs/heads/master' } + it { is_expected.to contain 'ref: refs/heads/master' } end end @@ -63,11 +63,11 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo_sha/.git") do - it { should be_directory } + it { is_expected.to be_directory } end describe file("#{tmpdir}/testrepo_sha/.git/HEAD") do - it { should contain sha } + it { is_expected.to contain sha } end end @@ -88,7 +88,7 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo_tag/.git") do - it { should be_directory } + it { is_expected.to be_directory } end it 'should have the tag as the HEAD' do @@ -113,11 +113,11 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo_branch/.git") do - it { should be_directory } + it { is_expected.to be_directory } end describe file("#{tmpdir}/testrepo_branch/.git/HEAD") do - it { should contain 'ref: refs/heads/a_branch' } + it { is_expected.to contain 'ref: refs/heads/a_branch' } end end @@ -183,7 +183,7 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo_shallow/.git/shallow") do - it { should be_file } + it { is_expected.to be_file } end end @@ -229,8 +229,8 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo_owner") do - it { should be_directory } - it { should be_owned_by 'vagrant' } + it { is_expected.to be_directory } + it { is_expected.to be_owned_by 'vagrant' } end end @@ -259,8 +259,8 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo_group") do - it { should be_directory } - it { should be_grouped_into 'vagrant' } + it { is_expected.to be_directory } + it { is_expected.to be_grouped_into 'vagrant' } end end @@ -281,8 +281,15 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo_excludes/.git/info/exclude") do - its(:content) { should match /exclude1.txt/ } - its(:content) { should match /exclude2.txt/ } + describe '#content' do + subject { super().content } + it { is_expected.to match /exclude1.txt/ } + end + + describe '#content' do + subject { super().content } + it { is_expected.to match /exclude2.txt/ } + end end end @@ -308,15 +315,15 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo_force/folder") do - it { should_not be_directory } + it { is_expected.not_to be_directory } end describe file("#{tmpdir}/testrepo_force/temp.txt") do - it { should_not be_file } + it { is_expected.not_to be_file } end describe file("#{tmpdir}/testrepo_force/.git") do - it { should be_directory } + it { is_expected.to be_directory } end context 'and noop' do @@ -382,13 +389,13 @@ describe 'clones a remote repo' do end describe file("#{tmpdir}/testrepo_user") do - it { should be_directory } - it { should be_owned_by 'testuser' } + it { is_expected.to be_directory } + it { is_expected.to be_owned_by 'testuser' } end describe file("#{tmpdir}/testrepo_user") do - it { should be_directory } - it { should be_grouped_into 'testuser' } + it { is_expected.to be_directory } + it { is_expected.to be_grouped_into 'testuser' } end end -- cgit v1.2.3 From 56f25d57dfa26de618416e9bdd4a853296ffcbc1 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 26 Dec 2014 15:27:20 -0800 Subject: MODULES-1596 - Repository repeatedly destroyed/created with force The `retrieve` method was calling `create` and `destroy` on every run with `force => true`. Retrieve should not be making any changes to the system, so removed that code, and updated `working_copy_exists` to make sure that the directory not only contains a `.git` directory, but also if `source` is specified it also matches `#{path}/.git/config` so that it will overwrite a git repo with a different source. Updated tests to not check for the old broken behavior. Added a regression test. --- spec/acceptance/clone_repo_spec.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'spec/acceptance/clone_repo_spec.rb') diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index f3e77db..4e9293b 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -350,9 +350,7 @@ describe 'clones a remote repo' do } EOS - apply_manifest(pp, :catch_changes => true) do |r| - expect(r.stdout).to match(/Noop Mode/) - end + apply_manifest(pp, :catch_changes => true) end end end -- cgit v1.2.3 From 68fc802b937334eda195f28c645e43b23d3ff061 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 14 Jan 2015 08:47:57 -0800 Subject: Remove let use as variable. Since lets can't be used in before :all any more. --- spec/acceptance/clone_repo_spec.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'spec/acceptance/clone_repo_spec.rb') diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index 4e9293b..2cca061 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -327,21 +327,18 @@ describe 'clones a remote repo' do end context 'and noop' do - let(:repo_name) do - 'testrepo_already_exists' - end before(:all) do - shell("mkdir #{tmpdir}/#{repo_name}") - shell("cd #{tmpdir}/#{repo_name} && git init") - shell("cd #{tmpdir}/#{repo_name} && touch a && git add a && git commit -m 'a'") + shell("mkdir #{tmpdir}/testrepo_already_exists") + shell("cd #{tmpdir}/testrepo_already_exists && git init") + shell("cd #{tmpdir}/testrepo_already_exists && touch a && git add a && git commit -m 'a'") end after(:all) do - shell("rm -rf #{tmpdir}/#{repo_name}") + shell("rm -rf #{tmpdir}/testrepo_already_exists") end it 'applies the manifest' do pp = <<-EOS - vcsrepo { "#{tmpdir}/#{repo_name}": + vcsrepo { "#{tmpdir}/testrepo_already_exists": ensure => present, source => "file://#{tmpdir}/testrepo.git", provider => git, -- cgit v1.2.3 From 8d3e112fec38627096e7d18d796e3abeaf677d66 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Fri, 29 May 2015 13:00:42 +0100 Subject: acceptance: Add a test verifying anonymous https cloning In MODULES-891 the question arose whether https sources are supported. This test shows that it works. --- spec/acceptance/clone_repo_spec.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'spec/acceptance/clone_repo_spec.rb') diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index 2cca061..c234550 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -38,6 +38,30 @@ describe 'clones a remote repo' do end end + context 'using a https source on github' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/httpstestrepo": + ensure => present, + provider => git, + source => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git", + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/httpstestrepo/.git") do + it { is_expected.to be_directory } + end + + describe file("#{tmpdir}/httpstestrepo/.git/HEAD") do + it { is_expected.to contain 'ref: refs/heads/master' } + end + end + context 'using a commit SHA' do let (:sha) do shell("git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1").stdout.chomp -- cgit v1.2.3