Skip to content

Commit 3dea8e2

Browse files
committed
ArgumentError doesn’t take arguments
Seems this codepath wasn’t tested ever so adding a test so that we’re covered.
1 parent 7d4c267 commit 3dea8e2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/fog/compute/google/models/servers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def get_public_key(public_key_path)
109109
end
110110

111111
if public_key_path.nil? || public_key_path.empty?
112-
raise ArgumentError("cannot bootstrap instance without public key file")
112+
raise Fog::Errors::Error.new("Cannot bootstrap instance without a public key")
113113
end
114114

115115
File.read(File.expand_path(public_key_path))

test/integration/compute/test_servers.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ def test_bootstrap
4141
"Bootstrapped server should have an external ip by default")
4242
end
4343
end
44+
45+
def test_bootstrap_fail
46+
# Pretend the ssh key does not exist
47+
File.stub :exist?, nil do
48+
assert_raises(Fog::Errors::Error) {
49+
@subject.bootstrap(:name => "#{CollectionFactory::PREFIX}-#{Time.now.to_i}",
50+
:public_key_path => nil)
51+
}
4452
end
4553
end
4654
end

0 commit comments

Comments
 (0)