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

Build a complete mock OS object #206

Merged
merged 1 commit into from
Nov 9, 2017
Merged

Conversation

adamleff
Copy link
Contributor

@adamleff adamleff commented Nov 6, 2017

InSpec expects there to be four parameters on every OS object: name, release, family, and arch. When the mock backend is used, only "family" is ever populated. When evaluating blocks, such as an only_if block, when the mock backend is used, errors will be encountered if someone tries to do something like:

os.name.include?('something')

... because os.name will be nil during an inspec check, for example.

This change properly populates all four expected parameters of the OS whenever the mock backend is used. The mock_os method still allows for one-off setting of the value as needed for unit tests, but it's now merged with the default four values.

Related to inspec/inspec#2250

InSpec expects there to be four parameters on every OS object:
name, release, family, and arch. When the mock backend is used,
only "family" is ever populated. When evaluating blocks, such
as an only_if block, when the mock backend is used, errors will be
encountered if someone tries to do something like:

os.name.include?('something')

... because `os.name` will be nil during an inspec check, for example.

This change properly populates all four expected parameters of the OS
whenever the mock backend is used. The `mock_os` method still allows
for one-off setting of the value as needed for unit tests, but it's
now merged with the default four values.

Signed-off-by: Adam Leff <adam@leff.co>
@adamleff adamleff requested a review from a team November 6, 2017 18:25
Copy link
Contributor

@chris-rock chris-rock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great improvement @adamleff

@chris-rock chris-rock merged commit a6373a8 into master Nov 9, 2017
@chris-rock chris-rock deleted the adamleff/mock-os-params branch November 9, 2017 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants