From bc4d91566bec422163c3b9b4de1b8a03d91fcc47 Mon Sep 17 00:00:00 2001 From: Maksim Paskal Date: Wed, 20 Mar 2024 08:03:48 +0000 Subject: [PATCH] fix codecov settings Signed-off-by: Maksim Paskal --- codecov.yml | 10 ++++++++++ pkg/config/config_test.go | 13 ++++++------- pkg/template/template_test.go | 2 +- pkg/types/types_test.go | 2 -- pkg/webhook/webhook_test.go | 5 ++--- 5 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..dd8e2ce --- /dev/null +++ b/codecov.yml @@ -0,0 +1,10 @@ +ignore: +# ignore cmd/main.go because it's a main file +- "cmd/main.go" +# ignore because to test need active connection to the Telegram +- "pkg/alert/alert.go" +# ignore because to test need active connection to the kubernetes cluster +- "pkg/web/web.go" +- "pkg/api/api.go" +- "pkg/events/events.go" +- "pkg/client/client.go" \ No newline at end of file diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 184a9ba..612cabf 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -139,18 +139,17 @@ func TestConfig(t *testing.T) { }, } - for _, testCase := range testCases { - tc := testCase - t.Run(testCase.testName, func(t *testing.T) { + for i := range testCases { + t.Run(testCases[i].testName, func(t *testing.T) { newConfig := config.Type{ - TaintEffect: &tc.taintEffect, - NodeName: &tc.nodeName, - TelegramChatID: &tc.telegramID, + TaintEffect: &testCases[i].taintEffect, + NodeName: &testCases[i].nodeName, + TelegramChatID: &testCases[i].telegramID, } config.Set(newConfig) err := config.Check() - if tc.err { + if testCases[i].err { require.Error(t, err) } else { require.NoError(t, err) diff --git a/pkg/template/template_test.go b/pkg/template/template_test.go index 253869b..76528da 100644 --- a/pkg/template/template_test.go +++ b/pkg/template/template_test.go @@ -100,7 +100,7 @@ func printType(prefix string, message interface{}) { v := reflect.ValueOf(message) typeOfS := v.Type() - for i := 0; i < v.NumField(); i++ { + for i := range v.NumField() { switch typeOfS.Field(i).Name { case "Template": case "Event": diff --git a/pkg/types/types_test.go b/pkg/types/types_test.go index d60d221..f906822 100644 --- a/pkg/types/types_test.go +++ b/pkg/types/types_test.go @@ -84,8 +84,6 @@ func TestAzureResource(t *testing.T) { }) for testID, test := range tests { - test := test - t.Run("Test"+strconv.Itoa(testID), func(t *testing.T) { t.Parallel() diff --git a/pkg/webhook/webhook_test.go b/pkg/webhook/webhook_test.go index bd1b4a3..16100ef 100644 --- a/pkg/webhook/webhook_test.go +++ b/pkg/webhook/webhook_test.go @@ -150,9 +150,8 @@ func TestWebHook(t *testing.T) { //nolint:funlen,tparallel } } - for _, test := range tests { //nolint:paralleltest - tc := test - t.Run(test.Name, func(t *testing.T) { + for _, tc := range tests { //nolint:paralleltest + t.Run(tc.Name, func(t *testing.T) { cleanAllFlags() for key, value := range tc.Args {