Skip to content

Commit 0a19eab

Browse files
author
Kevin Paulisse
committed
Add integration for script path override
1 parent feb4ede commit 0a19eab

2 files changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# For test purposes only, this script would ordinarily run a git checkout, but here
4+
# it's going to generate a directory structure by copying some other fixture.
5+
6+
if [ -z "$OCD_GIT_EXTRACT_BRANCH" ]; then
7+
echo "Error: Must declare OCD_GIT_EXTRACT_BRANCH"
8+
exit 255
9+
fi
10+
11+
if [ -z "$OCD_GIT_EXTRACT_TARGET" ]; then
12+
echo "Error: Must declare OCD_GIT_EXTRACT_TARGET"
13+
exit 255
14+
fi
15+
16+
if [ -z "$FIXTURE_DIR" ]; then
17+
echo "Error: Must declare FIXTURE_DIR"
18+
exit 255
19+
fi
20+
21+
set -euf -o pipefail
22+
cd "${FIXTURE_DIR}/${OCD_GIT_EXTRACT_BRANCH}"
23+
tar -cf - . | ( cd "$OCD_GIT_EXTRACT_TARGET" && tar -xf - )
24+
mkdir -p "$OCD_GIT_EXTRACT_TARGET/environments"
25+
ln -s "$OCD_GIT_EXTRACT_TARGET" "$OCD_GIT_EXTRACT_TARGET/environments/production"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# frozen_string_literal: true
2+
3+
require_relative 'integration_helper'
4+
5+
describe 'script path override' do
6+
context 'without any scripts' do
7+
it 'should fail' do
8+
result = OctocatalogDiff::Integration.integration(
9+
spec_fact_file: 'facts.yaml',
10+
argv: [
11+
'-n', 'rspec-node.github.net', '--no-parallel',
12+
'-t', 'ignore-tags-new', '-f', 'ignore-tags-old',
13+
'--basedir', OctocatalogDiff::Spec.fixture_path('repos/default'),
14+
'--override-script-path', OctocatalogDiff::Spec.fixture_path('scripts')
15+
]
16+
)
17+
expect(result.exitcode).to eq(-1)
18+
expect(result.logs).to match(/Git checkout error: Git archive ignore-tags-old->/)
19+
end
20+
end
21+
22+
context 'with an overridden git-extract.sh script' do
23+
before(:each) do
24+
ENV['FIXTURE_DIR'] = OctocatalogDiff::Spec.fixture_path('repos')
25+
end
26+
27+
after(:each) do
28+
ENV.delete('FIXTURE_DIR')
29+
end
30+
31+
it 'should return expected diff' do
32+
result = OctocatalogDiff::Integration.integration(
33+
spec_fact_file: 'facts.yaml',
34+
argv: [
35+
'-n', 'rspec-node.github.net', '--no-parallel',
36+
'-t', 'ignore-tags-new', '-f', 'ignore-tags-old',
37+
'--basedir', OctocatalogDiff::Spec.fixture_path('repos/default'),
38+
'--pass-env-vars', 'FIXTURE_DIR',
39+
'--override-script-path', OctocatalogDiff::Spec.fixture_path('override-scripts')
40+
]
41+
)
42+
expect(result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(result)
43+
expect(result.logs).to match(/Selecting.+git-extract.sh from override script path/)
44+
expect(result.diffs.size).to eq(30) # See ignore_tags_spec.rb
45+
end
46+
end
47+
end

0 commit comments

Comments
 (0)