Skip to content

Commit

Permalink
[chore] Failure on 1st test run should not cause 2nd run to fail (ope…
Browse files Browse the repository at this point in the history
  • Loading branch information
pjanotti authored and jriguera committed Oct 4, 2024
1 parent a8c4b11 commit e8fe806
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions receiver/windowseventlogreceiver/receiver_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"encoding/xml"
"path/filepath"
"reflect"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -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))
}
Expand Down

0 comments on commit e8fe806

Please sign in to comment.