Skip to content

Commit 69001ee

Browse files
authored
Merge pull request #240 from selmanj/works_with_empty_snapshots
Check for empty snapshots when listing
2 parents b7df99a + d883b26 commit 69001ee

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def all
99
next_page_token = nil
1010
loop do
1111
data = service.list_snapshots(nil, next_page_token)
12-
items.concat(data.body["items"])
12+
items.concat(data.body["items"]) unless data.body["items"].nil?
1313
next_page_token = data.body["nextPageToken"]
1414
break if next_page_token.nil? || next_page_token.empty?
1515
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require "helpers/integration_test_helper"
2+
require "securerandom"
3+
require "base64"
4+
5+
class TestComputeSnapshots < FogIntegrationTest
6+
def setup
7+
@client = Fog::Compute::Google.new
8+
# Ensure any resources we create with test prefixes are removed
9+
Minitest.after_run do
10+
delete_test_resources
11+
end
12+
end
13+
14+
def test_list_empty_snapshots
15+
assert_empty @client.snapshots.all
16+
end
17+
18+
def delete_test_resources
19+
# nothing to do
20+
end
21+
end

0 commit comments

Comments
 (0)