fog-openstack icon indicating copy to clipboard operation
fog-openstack copied to clipboard

Populating Mock Data in Orchestration Requests

Open davejohnston opened this issue 9 years ago • 1 comments
trafficstars

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.

davejohnston avatar Apr 25 '16 12:04 davejohnston

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

gildub avatar May 16 '16 23:05 gildub