From 8e1b3a178aefcc992895b27539b553035677f800 Mon Sep 17 00:00:00 2001 From: brokenpip3 Date: Wed, 13 Mar 2024 16:37:22 +0100 Subject: [PATCH] wip --- .golangci.yml | 6 +++++- api/v1alpha2/jenkins_webhook.go | 10 +++++++++- pkg/notifications/smtp/smtp_test.go | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 3118979a..9e66c045 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -13,6 +13,10 @@ issues: linters: - dupl - lll + - path: (.+)_test.go + linters: + - dupl + - lll linters: disable-all: true enable: @@ -26,7 +30,7 @@ linters: - gosimple - govet - ineffassign - - lll + #- lll - misspell - nakedret - prealloc diff --git a/api/v1alpha2/jenkins_webhook.go b/api/v1alpha2/jenkins_webhook.go index c99c8379..63ba9942 100644 --- a/api/v1alpha2/jenkins_webhook.go +++ b/api/v1alpha2/jenkins_webhook.go @@ -267,7 +267,11 @@ func (in *SecurityValidator) download() error { if err != nil { return err } - defer out.Close() + defer func() { + if err := out.Close(); err != nil { + jenkinslog.V(log.VDebug).Info("Failed to close file", err) + } + }() req, err := http.NewRequest(http.MethodGet, Hosturl, nil) if err != nil { @@ -286,6 +290,10 @@ func (in *SecurityValidator) download() error { defer response.Body.Close() + if err := out.Close(); err != nil { + jenkinslog.V(log.VDebug).Info("Failed to send file", err) + } + _, err = io.Copy(out, response.Body) return err } diff --git a/pkg/notifications/smtp/smtp_test.go b/pkg/notifications/smtp/smtp_test.go index d42035d4..2127263c 100644 --- a/pkg/notifications/smtp/smtp_test.go +++ b/pkg/notifications/smtp/smtp_test.go @@ -166,11 +166,11 @@ func TestSMTP_Send(t *testing.T) { }, }} - ts := &testServer{event: e} + //ts := &testServer{event: e} // Create fake SMTP server - s := smtp.NewServer(ts) + s := smtp.NewServer() s.Addr = fmt.Sprintf(":%d", testSMTPPort) s.Domain = "localhost"