Skip to content

Commit

Permalink
Removes usage of deprecated functions in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
chr-fritz committed Aug 30, 2023
1 parent 8753991 commit 86a17ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
7 changes: 4 additions & 3 deletions cmd/convertGa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package cmd

import (
"io/ioutil"
"os"
"testing"

Expand All @@ -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 {
Expand Down
11 changes: 6 additions & 5 deletions pkg/knx/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package knx

import (
"io/ioutil"
"os"
"testing"

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

0 comments on commit 86a17ba

Please sign in to comment.