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

Allow for testing that certain relationships aren't associated with a particular resource #605

Open
ITBlogger opened this issue Sep 11, 2017 · 3 comments

Comments

@ITBlogger
Copy link

ITBlogger commented Sep 11, 2017

Often we need to do logic where resources notify, subscribe, come before or require other resources under certain conditions, but DO NOT do the same in other conditions. Currently, it's not possible to test whether a given resource does not have a particular relationship with another, we can only test that relationships exist.

Please add the functionality to allow for testing that relationships do not exist for a given resource.

An example: We have 'production' and 'maintenance' modes of operation for systems:

class foo (
  Enum['production', 'maintenance'] $operating_mode,
) {

  if $operating_mode == 'maintenance' {
    File {
      owner => '0',
    }
  } else {
    File {
      owner => '0',
      notify  => Service['bar'],
    }
  }

  file { '/some/file':
    ensure => file,
  }

  service { 'bar':
    ensure => running,
  }
}

Should be able to have two rspec contexts 'production' and 'maintenance' and in maintenance context test that file '/some/file' does not notify service 'bar'

@DavidS
Copy link
Collaborator

DavidS commented Sep 12, 2017

Yep, currently it's only possible to say

it { is_expected.to contain_file('a').that_notifies(['File[b]', 'File[c]']) }

And rspec's negation feature only works on the whole clause, that would be

it { is_expected.not_to contain_file('a').that_notifies(['File[b]', 'File[c]']) }

which is obviously not the intended expectation in this case.

@rodjek
Copy link
Owner

rodjek commented Oct 2, 2017

@ITBlogger You might be interested in the proposal in #611

@ITBlogger
Copy link
Author

@rodjek Yep, that most definitely meets my needs, thanks!

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

No branches or pull requests

3 participants