From 2d293e6504be83a9115513a7c14045c776216cc9 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Fri, 10 May 2024 11:21:22 -0400 Subject: [PATCH] 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. --- packer_test/pipe_checker_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packer_test/pipe_checker_test.go b/packer_test/pipe_checker_test.go index 9762b020c..f5f5501f3 100644 --- a/packer_test/pipe_checker_test.go +++ b/packer_test/pipe_checker_test.go @@ -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) }