You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, I'm not entirely sure if this a bug in fog-openstack - or an incorrect assumption made in fog-core (I'd say a bit of both).
The problem is that if I understand correctly, if one wishes to reset the mocks when testing, this can be achieved by calling
Fog::Mock.reset
The reset method is implemented in fog-core:
def self.reset
mocked_services = []
Fog.constants.map do |x|
next if Fog.autoload?(x)
x_const = Fog.const_get(x)
x_const.respond_to?(:constants) && x_const.constants.map do |y|
next if x_const.autoload?(y)
y_const = x_const.const_get(y)
y_const.respond_to?(:constants) && y_const.constants.map do |z|
next if y_const.autoload?(z)
mocked_services << y_const.const_get(z) if z.to_sym == :Mock
end
end
end
mocked_services.each do |mocked_service|
next unless mocked_service.respond_to?(:reset)
mocked_service.reset
end
end
So: get constants under Fog (i.e. :Image), get constants under Fog::Image (i.e. :OpenStack) and then get from Fog::Image::OpenStack - if one of them is called :Mock, make it a candidate for resetting.
The problem is that there are different classes for different versions of Glance API: i.e. Fog::Image::OpenStack::V1::Mock - so the Mock class in the hierarchy is under V1, not under OpenStack, where fog-core is searching for it.
Until this issue is fixed, a workaround is to i.e. call:
to manually reset those mocks - however, I think that a proper solution would need to be added. I think that the same issue will apply to other implementations of versioned APIs (i.e. Keystone), though I didn't check this.
The text was updated successfully, but these errors were encountered:
So, I'm not entirely sure if this a bug in
fog-openstack
- or an incorrect assumption made infog-core
(I'd say a bit of both).The problem is that if I understand correctly, if one wishes to reset the mocks when testing, this can be achieved by calling
The
reset
method is implemented infog-core
:So: get constants under
Fog
(i.e.:Image
), get constants underFog::Image
(i.e.:OpenStack
) and then get fromFog::Image::OpenStack
- if one of them is called:Mock
, make it a candidate for resetting.The problem is that there are different classes for different versions of Glance API: i.e.
Fog::Image::OpenStack::V1::Mock
- so theMock
class in the hierarchy is underV1
, not underOpenStack
, wherefog-core
is searching for it.Until this issue is fixed, a workaround is to i.e. call:
to manually reset those mocks - however, I think that a proper solution would need to be added. I think that the same issue will apply to other implementations of versioned APIs (i.e. Keystone), though I didn't check this.
The text was updated successfully, but these errors were encountered: