fog / fog-openstack

Fog for OpenStack Platform
MIT License
69 stars 130 forks source link

Populating Mock Data in Orchestration Requests #86

Open davejohnston opened 8 years ago

davejohnston commented 8 years ago

I'm currently writing tests for code that uses Openstack Orchestration requests.

One of the test fails, when I looked at the Mock for list_resources

`class Mock def list_resources(options = {}, options_deprecated = {}) puts "YYY Resources: #{self.data}" resources = self.data[:resources].values

      Excon::Response.new(
        :body   => { 'resources' => resources },
        :status => 200
      )
    end
  end

`

The error occurs because self.data[:resources] is nil, so .values being called on a Nil class. Is there a correct method to populate self.data? in the Mock class, prior to executing the test?
I can't see a recommended approach.

gildub commented 8 years ago

Setup a set of default test values to the Mock class into the data method.