When copying test binary, delete first (#19331)

For plugin tests, we copy the test binary. On macOS, if the
destination binary already exists, then copying over it will result
in an invalid signature.

The easiest workaround is to delete the file before copying.
This commit is contained in:
Christopher Swenson 2023-02-23 15:10:13 -08:00 committed by GitHub
parent f2a47b0e40
commit 794eb8b2e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -526,6 +526,9 @@ func TestAddTestPlugin(t testing.T, c *Core, name string, pluginType consts.Plug
// Copy over the file to the temp dir
dst := filepath.Join(tempDir, fileName)
// delete the file first to avoid notary failures in macOS
_ = os.Remove(dst) // ignore error
out, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fi.Mode())
if err != nil {
t.Fatal(err)