-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
assert.out.none
and assert.err.none
to exec
Makes the assertion fields of the exec plugin's `assert` struct more flexible and adds a new `assert.out.none` and `assert.err.none` field that contains a string or strings that should *not* appear in either stdout or stderr pipes from the exec command. The `plugin/exec.PipeExpect` struct now contains three fields, each of which are `types.FlexStrings` that can contain either a string or a list of strings. There is now a custom YAML unmarshaler for `PipeExpect` which allows a flexible naming convention to be used for specifying assertions: All of these examples are valid and represent human-readable assertions: ```yaml tests: # Variants of contains - exec: ls -l assert: out: contains: - parse.go - exec: ls -l assert: out: is: parse.go - exec: ls -l assert: out: is: - parse.go - exec: ls -l assert: out: contains: parse.go - exec: ls -l assert: out: contains-all: - parse.go - exec: ls -l assert: out: all: parse.go # Variants of contains-any - exec: ls -l assert: out: any: - thisdoesnotexist - neitherdoesthisexist - parse.go - exec: ls -l assert: out: contains_one_of: - thisdoesnotexist - neitherdoesthisexist - parse.go - exec: ls -l assert: out: contains-any: - parse.go - exec: ls -l assert: out: any: parse.go # Variants of contains-none-of - exec: ls -l assert: out: none: - notexisting.go - exec: ls -l assert: out: none-of: notexisting.go - exec: ls -l assert: out: contains_none_of: - notexisting.go - exec: ls -l assert: out: none-of: notexisting.go ``` Signed-off-by: Jay Pipes <jaypipes@gmail.com>
- Loading branch information
Showing
11 changed files
with
194 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: ls-contains-none-of | ||
description: a scenario that runs the `ls` command and checks the output does not contain a string | ||
tests: | ||
- exec: ls -l | ||
assert: | ||
out: | ||
none: | ||
- notexisting.go | ||
# Variants of contains-none-of | ||
- exec: ls -l | ||
assert: | ||
out: | ||
none-of: notexisting.go | ||
- exec: ls -l | ||
assert: | ||
out: | ||
contains_none_of: | ||
- notexisting.go | ||
- exec: ls -l | ||
assert: | ||
out: | ||
none-of: notexisting.go | ||
# To test the stderr assertions, we redirect stdout to stderr in a shell | ||
# command... | ||
- exec: "ls -l 1>&2" | ||
shell: sh | ||
assert: | ||
err: | ||
none: | ||
- notexisting.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,37 @@ | ||
name: ls-contains-one-of | ||
description: a scenario that runs the `ls` command and checks the output contains one of a set of strings | ||
tests: | ||
- exec: ls -l | ||
assert: | ||
out: | ||
any: | ||
- thisdoesnotexist | ||
- neitherdoesthisexist | ||
- parse.go | ||
# Variants of contains-any | ||
- exec: ls -l | ||
assert: | ||
out: | ||
contains_one_of: | ||
- thisdoesnotexist | ||
- neitherdoesthisexist | ||
- parse.go | ||
- exec: ls -l | ||
assert: | ||
out: | ||
contains-any: | ||
- parse.go | ||
- exec: ls -l | ||
assert: | ||
out: | ||
any: parse.go | ||
# To test the stderr assertions, we redirect stdout to stderr in a shell | ||
# command... | ||
- exec: "ls -l 1>&2" | ||
shell: sh | ||
assert: | ||
err: | ||
contains_one_of: | ||
any: | ||
- thisdoesnotexist | ||
- neitherdoesthisexist | ||
- parse.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters