forked from openshift/rhc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openshift#466 from caruccio/master
Merged by openshift-bot
- Loading branch information
Showing
6 changed files
with
61 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,13 +13,13 @@ | |
user_config | ||
@app = rest_client.add_domain("mockdomain").add_application APP_NAME, 'mock-1.0' | ||
@ssh_uri = URI.parse @app.ssh_url | ||
filename = APP_NAME + '.tar.gz' | ||
FileUtils.cp(File.expand_path('../../assets/targz_sample.tar.gz', __FILE__), filename) | ||
@targz_filename = APP_NAME + '.tar.gz' | ||
FileUtils.cp(File.expand_path('../../assets/targz_sample.tar.gz', __FILE__), @targz_filename) | ||
File.chmod 0644, @targz_filename unless File.executable? @targz_filename | ||
end | ||
|
||
after do | ||
filename = APP_NAME + '.tar.gz' | ||
File.delete filename if File.exist? filename | ||
File.delete @targz_filename if File.exist? @targz_filename | ||
end | ||
|
||
describe 'snapshot without an action' do | ||
|
@@ -41,6 +41,7 @@ | |
context 'when failing to save a snapshot' do | ||
before(:each) do | ||
`(exit 1)` | ||
subject.class.any_instance.should_receive(:has_ssh?).and_return(true) | ||
Kernel.should_receive(:`).with("ssh #{@ssh_uri.user}@#{@ssh_uri.host} 'snapshot' > #{@app.name}.tar.gz") | ||
end | ||
it { expect { run }.to exit_with_code(130) } | ||
|
@@ -72,6 +73,16 @@ | |
|
||
end | ||
|
||
describe 'snapshot save with invalid ssh executable' do | ||
let(:arguments) {['snapshot', 'save', '--trace', '--noprompt', '-l', '[email protected]', '-p', 'password', '--app', 'mockapp', '--ssh', 'path_to_ssh']} | ||
it('should raise') { expect{ run }.to raise_error(RHC::InvalidSSHExecutableException, /SSH executable 'path_to_ssh' does not exist./) } | ||
end | ||
|
||
describe 'snapshot save when ssh is not executable' do | ||
let(:arguments) {['snapshot', 'save', '--trace', '--noprompt', '-l', '[email protected]', '-p', 'password', '--app', 'mockapp', '--ssh', @targz_filename]} | ||
it('should raise') { expect{ run }.to raise_error(RHC::InvalidSSHExecutableException, /SSH executable '#{@targz_filename}' is not executable./) } | ||
end | ||
|
||
describe 'snapshot restore' do | ||
let(:arguments) {['snapshot', 'restore', '--noprompt', '-l', '[email protected]', '-p', 'password', '--app', 'mockapp']} | ||
|
||
|
@@ -89,6 +100,7 @@ | |
before(:each) do | ||
File.stub(:exists?).and_return(true) | ||
RHC::TarGz.stub(:contains).and_return(true) | ||
subject.class.any_instance.should_receive(:has_ssh?).and_return(true) | ||
Kernel.should_receive(:`).with("cat '#{@app.name}.tar.gz' | ssh #{@ssh_uri.user}@#{@ssh_uri.host} 'restore INCLUDE_GIT'") | ||
$?.stub(:exitstatus) { 1 } | ||
end | ||
|
@@ -142,5 +154,14 @@ | |
end | ||
end | ||
|
||
describe 'snapshot restore with invalid ssh executable' do | ||
let(:arguments) {['snapshot', 'restore', '--trace', '--noprompt', '-l', '[email protected]', '-p', 'password', '--app', 'mockapp', '--ssh', 'path_to_ssh']} | ||
it('should raise') { expect{ run }.to raise_error(RHC::InvalidSSHExecutableException, /SSH executable 'path_to_ssh' does not exist./) } | ||
end | ||
|
||
describe 'snapshot save when ssh is not executable' do | ||
let(:arguments) {['snapshot', 'restore', '--trace', '--noprompt', '-l', '[email protected]', '-p', 'password', '--app', 'mockapp', '--ssh', @targz_filename]} | ||
it('should raise') { expect{ run }.to raise_error(RHC::InvalidSSHExecutableException, /SSH executable '#{@targz_filename}' is not executable./) } | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters