From e85de6640c60bb028c5cc2d670c0b99f690463f5 Mon Sep 17 00:00:00 2001 From: Dan Jaglowski Date: Fri, 21 May 2021 13:23:44 -0400 Subject: [PATCH] Fix problem with fingerprint test --- operator/builtin/input/file/fingerprint_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/operator/builtin/input/file/fingerprint_test.go b/operator/builtin/input/file/fingerprint_test.go index fe5e26c8..d718f39c 100644 --- a/operator/builtin/input/file/fingerprint_test.go +++ b/operator/builtin/input/file/fingerprint_test.go @@ -254,16 +254,23 @@ func TestFingerprintStartsWith_FromFile(t *testing.T) { partialFile, err := ioutil.TempFile(tempDir, "") require.NoError(t, err) + // Write the first byte before comparing, since empty files will never match + _, err = partialFile.Write(content[:1]) + require.NoError(t, err) + content = content[1:] + // Write one byte at a time and validate that updated // full fingerprint still starts with partial for i := range content { _, err = partialFile.Write(content[i:i]) require.NoError(t, err) - pff, err := operator.NewFingerprint(fullFile) + pff, err := operator.NewFingerprint(partialFile) require.NoError(t, err) - require.True(t, fff.StartsWith(pff)) + match := fff.StartsWith(pff) + + require.True(t, match) } }