mirror of
https://github.com/hashicorp/packer.git
synced 2026-06-09 08:42:33 -04:00
packer_test: add convenience func for line count
When building a pipeline to count the number of lines returned by Packer, it can be a bit cumbersome to have to chain the calls to MkPipeCheck to do that check, so we add one convenience function for the simplest case: counting the number of lines on stdout, without any kind of filtering.
This commit is contained in:
parent
c6388d4680
commit
3661d97fc0
1 changed files with 10 additions and 0 deletions
|
|
@ -158,3 +158,13 @@ func (c CustomCheck) Check(stdout, stderr string, err error) error {
|
|||
func (c CustomCheck) Name() string {
|
||||
return fmt.Sprintf("custom check - %s", c.name)
|
||||
}
|
||||
|
||||
// LineCountCheck builds a pipe checker to count the number of lines on stdout by default
|
||||
//
|
||||
// To change the stream(s) on which to perform the check, you can call SetStream on the
|
||||
// returned pipe checker.
|
||||
func LineCountCheck(lines int) *PipeChecker {
|
||||
return MkPipeCheck(fmt.Sprintf("line count (%d)", lines), LineCount()).
|
||||
SetTester(IntCompare(eq, lines)).
|
||||
SetStream(OnlyStdout)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue