From 86a17ba95b7d10d4fa7a511c61bf4ec8af8f4a9f Mon Sep 17 00:00:00 2001 From: Christian Fritz Date: Wed, 30 Aug 2023 23:06:29 +0200 Subject: [PATCH] Removes usage of deprecated functions in tests. --- cmd/convertGa_test.go | 7 ++++--- pkg/knx/converter_test.go | 11 ++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cmd/convertGa_test.go b/cmd/convertGa_test.go index 85f3ae9..1d9d89d 100644 --- a/cmd/convertGa_test.go +++ b/cmd/convertGa_test.go @@ -15,7 +15,6 @@ package cmd import ( - "io/ioutil" "os" "testing" @@ -33,9 +32,11 @@ func TestRunConvertGaCommand(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - tmpFile, err := ioutil.TempFile("", "") + tmpFile, err := os.CreateTemp("", "") assert.NoError(t, err) - defer os.Remove(tmpFile.Name()) + defer func() { + _ = os.Remove(tmpFile.Name()) + }() cmd := NewConvertGaCommand() if err := cmd.RunE(nil, []string{tt.src, tmpFile.Name()}); (err != nil) != tt.wantErr { diff --git a/pkg/knx/converter_test.go b/pkg/knx/converter_test.go index 7d2d9af..e583a6e 100644 --- a/pkg/knx/converter_test.go +++ b/pkg/knx/converter_test.go @@ -15,7 +15,6 @@ package knx import ( - "io/ioutil" "os" "testing" @@ -35,9 +34,11 @@ func TestConvertGroupAddresses(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - tmpFile, err := ioutil.TempFile("", "") + tmpFile, err := os.CreateTemp("", "") assert.NoError(t, err) - defer os.Remove(tmpFile.Name()) + defer func() { + _ = os.Remove(tmpFile.Name()) + }() if err := ConvertGroupAddresses(tt.src, tmpFile.Name()); (err != nil) != tt.wantErr { t.Errorf("ConvertGroupAddresses() error = %v, wantErr %v", err, tt.wantErr) @@ -49,11 +50,11 @@ func TestConvertGroupAddresses(t *testing.T) { assert.FileExists(t, tmpFile.Name()) - expected, err := ioutil.ReadFile(tt.wantTarget) + expected, err := os.ReadFile(tt.wantTarget) assert.NoError(t, err) expected, err = yaml.YAMLToJSON(expected) assert.NoError(t, err) - actual, err := ioutil.ReadFile(tmpFile.Name()) + actual, err := os.ReadFile(tmpFile.Name()) assert.NoError(t, err) actual, err = yaml.YAMLToJSON(actual) assert.NoError(t, err)