mirror of
https://github.com/hashicorp/packer.git
synced 2026-06-09 08:42:33 -04:00
packer_test: add convenience func for invert grep
As inverted grep is something we do rather often, we add a convenience function to create an inverted grep gadget.
This commit is contained in:
parent
064a00e9db
commit
dbd441f6f3
5 changed files with 11 additions and 7 deletions
|
|
@ -17,7 +17,7 @@ func (ts *PackerCoreTestSuite) TestEvalLocalsOrder() {
|
|||
Stdin("local.test_local\n").
|
||||
SetArgs("console", "./templates/locals_no_order.pkr.hcl").
|
||||
Assert(lib.MustSucceed(),
|
||||
lib.Grep("\\[\\]", lib.GrepStdout, lib.GrepInvert))
|
||||
lib.GrepInverted("\\[\\]", lib.GrepStdout))
|
||||
}
|
||||
|
||||
func (ts *PackerCoreTestSuite) TestLocalDuplicates() {
|
||||
|
|
|
|||
|
|
@ -125,6 +125,10 @@ func Grep(expression string, opts ...GrepOpts) Checker {
|
|||
return pc
|
||||
}
|
||||
|
||||
func GrepInverted(expression string, opts ...GrepOpts) Checker {
|
||||
return Grep(expression, append(opts, GrepInvert)...)
|
||||
}
|
||||
|
||||
type PluginVersionTuple struct {
|
||||
Source string
|
||||
Version *version.Version
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ func (ts *PackerPluginTestSuite) TestInstallPluginWithPath() {
|
|||
SetArgs("plugins", "installed").
|
||||
Assert(lib.MustSucceed(),
|
||||
lib.Grep("plugin-tester_v1.0.0-dev[^+]", lib.GrepStdout),
|
||||
lib.Grep("plugin-tester_v1.0.0-dev\\+", lib.GrepStdout, lib.GrepInvert),
|
||||
lib.GrepInverted("plugin-tester_v1.0.0-dev\\+", lib.GrepStdout),
|
||||
lib.LineCountCheck(1))
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ func (ts *PackerPluginTestSuite) TestLoadWithSHAMismatches() {
|
|||
SetArgs("plugins", "installed").
|
||||
Assert(lib.MustSucceed(),
|
||||
lib.Grep("packer-plugin-tester_v1\\.0\\.9[^\\n]+", lib.GrepStdout),
|
||||
lib.Grep("packer-plugin-tester_v1.0.10", lib.GrepStdout, lib.GrepInvert),
|
||||
lib.GrepInverted("packer-plugin-tester_v1.0.10", lib.GrepStdout),
|
||||
lib.Grep("v1.0.10[^\\n]+ignoring possibly unsafe binary", lib.GrepStderr))
|
||||
})
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ func (ts *PackerPluginTestSuite) TestLoadWithSHAMismatches() {
|
|||
SetArgs("plugins", "installed").
|
||||
Assert(lib.MustSucceed(),
|
||||
lib.Grep("packer-plugin-tester_v1\\.0\\.9[^\\n]+", lib.GrepStdout),
|
||||
lib.Grep("packer-plugin-tester_v1.0.10", lib.GrepInvert, lib.GrepStdout),
|
||||
lib.GrepInverted("packer-plugin-tester_v1.0.10", lib.GrepStdout),
|
||||
lib.Grep("v1.0.10[^\\n]+ignoring possibly unsafe binary", lib.GrepStderr),
|
||||
lib.Grep(`Checksums \(\*sha256\.digest\) did not match.`, lib.GrepStderr))
|
||||
})
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ func (ts *PackerPluginTestSuite) TestPluginsRemoveWithSourceAddressAndVersion()
|
|||
lib.MustSucceed(),
|
||||
lib.Grep("packer-plugin-tester_v1.0.9", lib.GrepStdout),
|
||||
lib.Grep("packer-plugin-tester_v1.0.10", lib.GrepStdout),
|
||||
lib.Grep("packer-plugin-tester_v2.0.0", lib.GrepInvert, lib.GrepStdout),
|
||||
lib.GrepInverted("packer-plugin-tester_v2.0.0", lib.GrepStdout),
|
||||
)
|
||||
})
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ func (ts *PackerPluginTestSuite) TestPluginsRemoveWithLocalPath() {
|
|||
Assert(
|
||||
lib.MustSucceed(),
|
||||
lib.Grep("packer-plugin-tester_v1.0.9", lib.GrepStdout),
|
||||
lib.Grep("packer-plugin-tester_v1.0.10", lib.GrepInvert, lib.GrepStdout),
|
||||
lib.GrepInverted("packer-plugin-tester_v1.0.10", lib.GrepStdout),
|
||||
)
|
||||
})
|
||||
ts.Run("plugins installed after calling plugins remove outputs remaining installed plugins", func() {
|
||||
|
|
@ -107,7 +107,7 @@ func (ts *PackerPluginTestSuite) TestPluginsRemoveWithLocalPath() {
|
|||
Assert(
|
||||
lib.MustSucceed(),
|
||||
lib.Grep("packer-plugin-tester_v1.0.10", lib.GrepStdout),
|
||||
lib.Grep("packer-plugin-tester_v1.0.9", lib.GrepInvert, lib.GrepStdout),
|
||||
lib.GrepInverted("packer-plugin-tester_v1.0.9", lib.GrepStdout),
|
||||
)
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue