Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for exported resource mocks #2

Open
saj opened this issue Jul 19, 2011 · 5 comments
Open

Add support for exported resource mocks #2

saj opened this issue Jul 19, 2011 · 5 comments
Labels

Comments

@saj
Copy link

saj commented Jul 19, 2011

Like what you have done with the fact mocks, but with exported resources.

This feature would kick arse.

rodjek pushed a commit that referenced this issue Aug 4, 2011
@ghost
Copy link

ghost commented Aug 20, 2012

Hi,

I would like to know how I can test if an exported resource has indeed been exported. Since this ticket in a year old, maybe there now is a way to do this ?

Thanks in advance

@hunner
Copy link
Collaborator

hunner commented Mar 13, 2013

The current object against which rspec-puppet checks is the completely compiled catalog, which only contains exported resources that are realized with the <<| |>> collector.

When working on #51 I worked for a while on trying to verify that resources were actually exported, but the only way I could think is to create a node definition in spec/hosts that realizes the resources you want to check, then check there.

One possible solution: there is a :precondition block for manifest code that is added at the beginning of the test, so perhaps a :postcondition would give you the ability to add <<| |>> collectors for checking.

@DavidS DavidS added the feature label Jun 22, 2015
@lmayorga1980
Copy link

👍

@kjetilho
Copy link
Contributor

this has been supported for a while, using a syntax like:

it do
  expect(exported_resources).to contain_nagios_host("foo.example")
                                .with_address("10.11.12.13")
end

(there may be more pretty ways of writing this as well)

@kjetilho
Copy link
Contributor

What is still impossible, as far as I can tell, is to test the collection operator, ie. that the correct subset of exported resources are realized in your catalog.

If I read the code correctly, it is impossible to check whether collect works, since the <<| |>> collect code (LLCOLLECT) requires storeconfigs to be enabled to do any work at all. This in turn requires a working puppetdb-terminus.

I did manage to hack together a matcher for the exported property, and with that I could verify that my collect statement worked by using <| |> (LCOLLECT) instead (yes, this collects both @ and @@). Ie., my resources would be be visible in the catalog using the normal generic_contain, and I could use my .exported() matcher to verify the origin of this resource.

This is hardly a usable workaround, but it may point in a possible direction for implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants