Skip to content

Commit

Permalink
Adding a test for set_server_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Temikus committed May 19, 2018
1 parent 1bf7669 commit 5db3f59
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lib/fog/compute/google/models/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,7 @@ def set_scheduling(async = true,
operation.wait_for { ready? } unless async
reload
end



# Set an instance metadata
#
# @param [Bool] async Perform the operation asyncronously
Expand Down
2 changes: 1 addition & 1 deletion lib/fog/compute/google/requests/set_server_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Real
# fingerprint = instance.metadata['fingerprint']
# @param [Hash] metadata A new metadata object
# Should have the following structure:
# {:items=>[{:key=>"foo", :value=>"bar"}, {:key=>"fefe", :value=>"bub"}]}
# {:items=>[{:key=>"foo", :value=>"bar"}, {:key=>"baz", :value=>"foo"}]}
#
# @returns [::Google::Apis::ComputeV1::Operation] set operation
def set_server_metadata(instance, zone, fingerprint, metadata_items = [])
Expand Down
9 changes: 9 additions & 0 deletions test/integration/compute/test_servers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@
class TestServers < FogIntegrationTest
include TestCollection

# Cleanup is handled by TestCollection
def setup
@subject = Fog::Compute[:google].servers
@factory = ServersFactory.new(namespaced_name)
end

def test_set_metadata
server = @factory.create
server.wait_for { ready? }
server.set_metadata({ 'foo' => 'bar', 'baz' => 'foo' }, false)
assert_equal [{ :key => "foo", :value => "bar" },
{ :key=>"baz", :value=>"foo" }], server.metadata[:items]
end
end

0 comments on commit 5db3f59

Please sign in to comment.