Skip to content

Instantly share code, notes, and snippets.

@lutter
Last active Mar 31, 2017
Embed
What would you like to do?
Provider testing
---
# Test the behavior of a specific provider.
#
# The tests will generally be destructive; there's no good way to mock what
# external providers do (we could try and intercept execve and/or open, but
# that would still leave lots of ways in which providers can alter a
# system)
desc: check sysv provider
# The name of the provider to test
provider: service::sysv
# Does this have to be run as root ?
sudo: true
setup:
# Bring our test system into a known state. In a way, this is a first
# test, as it will use the provider's set() to get us there and will log
# a failure if we can't get there
resources:
- name: atd
ensure: stopped
enabled: false
tests:
# An array of tests. Each test is either a test of get or of set
- desc: find a service
# Verify that a very basic get works. This is redundant with what 'setup' does;
# could there be a better way for get tests ?
get:
names: atd
result:
resources:
- name: atd
ensure: stopped
enabled: false
- desc: find a non-existing service
# Verify that the provider produces expected errors
get:
names: not_a_service
result:
error:
message: unknown resource not_a_service
- desc: start a service
# Modify state. The expected result, if not otherwise specified, is
# that set logs the right state transitions, and that a subsequent
# get() verifies that the changes were actually made
set:
resources:
- name: atd
ensure: running
- desc: change a nonexistent service
set:
resources:
- name: not_a_service
ensure: running
result:
error:
message: unknown resource not_a_service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment