From db787dd130d1d21f563735b28dbc0c979e93b414 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 13 Sep 2024 06:01:08 -0700 Subject: [PATCH] [chore] Failure on 1st test run should not cause 2nd run to fail (#35168) --- receiver/windowseventlogreceiver/receiver_windows_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/receiver/windowseventlogreceiver/receiver_windows_test.go b/receiver/windowseventlogreceiver/receiver_windows_test.go index 429d009ba30c..a97abdb06c30 100644 --- a/receiver/windowseventlogreceiver/receiver_windows_test.go +++ b/receiver/windowseventlogreceiver/receiver_windows_test.go @@ -10,6 +10,7 @@ import ( "encoding/xml" "path/filepath" "reflect" + "strings" "testing" "time" @@ -301,6 +302,10 @@ func createTestConfig() *WindowsLogConfig { // It returns a function that can be used to uninstall the event source, that function is never nil func assertEventSourceInstallation(t *testing.T, src string) (uninstallEventSource func(), err error) { err = eventlog.InstallAsEventCreate(src, eventlog.Info|eventlog.Warning|eventlog.Error) + if err != nil && strings.HasSuffix(err.Error(), " registry key already exists") { + // If the event source already exists ignore the error + err = nil + } uninstallEventSource = func() { assert.NoError(t, eventlog.Remove(src)) }