packer_test: fix int compare checker

The IntCompare checker converts the input string into an int through
strconv.Atoi, which fails when the string isn't valid base 10. This
definition of "valid" also excludes whitespace, which occurs often
through piping gadgets, but shouldn't be a reason to fail that check, so
we trim the whitespace from the input string.
pull/12983/head
Lucas Bajolet 2 years ago
parent 124a8d8d5d
commit 2d293e6504

@ -125,7 +125,7 @@ func (op op) String() string {
// If the input is not an int, this fails.
func IntCompare(op op, value int) Tester {
return CustomTester(func(in string) error {
n, err := strconv.Atoi(in)
n, err := strconv.Atoi(strings.TrimSpace(in))
if err != nil {
return fmt.Errorf("not an integer %q: %s", in, err)
}

Loading…
Cancel
Save