From bb953a488cf63ff684cdabfc90666d02f3c518d0 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Fri, 5 Jan 2024 14:47:33 -0800 Subject: [PATCH] [chore][receiver/windowseventlog] Fix lint on Windows (#30311) **Description:** Fixing lint issues when GOOS=windows. This is in preparation to eventually include lint with GOOS=windows as part of CI. --- .../receiver_windows_test.go | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/receiver/windowseventlogreceiver/receiver_windows_test.go b/receiver/windowseventlogreceiver/receiver_windows_test.go index 7b7c7e289a29..bb88c7b9aa6e 100644 --- a/receiver/windowseventlogreceiver/receiver_windows_test.go +++ b/receiver/windowseventlogreceiver/receiver_windows_test.go @@ -83,12 +83,16 @@ func TestReadWindowsEventLogger(t *testing.T) { err = receiver.Start(ctx, componenttest.NewNopHost()) require.NoError(t, err) - defer receiver.Shutdown(ctx) + defer func() { + require.NoError(t, receiver.Shutdown(ctx)) + }() src := "otel" err = eventlog.InstallAsEventCreate(src, eventlog.Info|eventlog.Warning|eventlog.Error) require.NoError(t, err) - defer eventlog.Remove(src) + defer func() { + require.NoError(t, eventlog.Remove(src)) + }() logger, err := eventlog.Open(src) require.NoError(t, err) @@ -144,11 +148,15 @@ func TestReadWindowsEventLoggerRaw(t *testing.T) { err = receiver.Start(ctx, componenttest.NewNopHost()) require.NoError(t, err) - defer receiver.Shutdown(ctx) + defer func() { + require.NoError(t, receiver.Shutdown(ctx)) + }() src := "otel" err = eventlog.InstallAsEventCreate(src, eventlog.Info|eventlog.Warning|eventlog.Error) - defer eventlog.Remove(src) + defer func() { + require.NoError(t, eventlog.Remove(src)) + }() require.NoError(t, err) logger, err := eventlog.Open(src) @@ -197,11 +205,15 @@ func TestReadWindowsEventLoggerWithExcludeProvider(t *testing.T) { err = receiver.Start(ctx, componenttest.NewNopHost()) require.NoError(t, err) - defer receiver.Shutdown(ctx) + defer func() { + require.NoError(t, receiver.Shutdown(ctx)) + }() err = eventlog.InstallAsEventCreate(src, eventlog.Info|eventlog.Warning|eventlog.Error) require.NoError(t, err) - defer eventlog.Remove(src) + defer func() { + require.NoError(t, eventlog.Remove(src)) + }() logger, err := eventlog.Open(src) require.NoError(t, err) @@ -237,10 +249,14 @@ func TestReadWindowsEventLoggerRawWithExcludeProvider(t *testing.T) { err = receiver.Start(ctx, componenttest.NewNopHost()) require.NoError(t, err) - defer receiver.Shutdown(ctx) + defer func() { + require.NoError(t, receiver.Shutdown(ctx)) + }() err = eventlog.InstallAsEventCreate(src, eventlog.Info|eventlog.Warning|eventlog.Error) - defer eventlog.Remove(src) + defer func() { + require.NoError(t, eventlog.Remove(src)) + }() require.NoError(t, err) logger, err := eventlog.Open(src)