Skip to content

Commit 8380665

Browse files
oliwermjuraga
authored andcommitted
REORG/MINOR: remove the last uses of io/ioutil
And remove 2 unused functions in the process.
1 parent acf5414 commit 8380665

File tree

6 files changed

+5
-32
lines changed

6 files changed

+5
-32
lines changed

.aspell.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ allowed:
8282
- httpCLF
8383
- ineffassign
8484
- infos
85+
- ioutil
8586
- ipam
8687
- istanbul
8788
- jose

spoe/spoe_client_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package spoe
1818
import (
1919
"bytes"
2020
"io"
21-
"io/ioutil"
2221
"os"
2322
"path/filepath"
2423
"testing"
@@ -54,7 +53,7 @@ func Test_spoeclient_Create(t *testing.T) {
5453
name: "Should create a file with # _version prepended",
5554
clients: make(map[string]*SingleSpoe),
5655
fileName: "spoe.cfg",
57-
readCloser: ioutil.NopCloser(bytes.NewReader([]byte("hello world"))),
56+
readCloser: io.NopCloser(bytes.NewReader([]byte("hello world"))),
5857
initParams: Params{
5958
SpoeDir: "/tmp",
6059
TransactionDir: "/tmp",

storage/storage_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package storage
1818
import (
1919
"bytes"
2020
"io"
21-
"io/ioutil"
2221
"path/filepath"
2322
"reflect"
2423
"testing"
@@ -374,7 +373,7 @@ func Test_storage_Create(t *testing.T) {
374373
name: "Should create file if not exists",
375374
dirname: dirWithoutFile,
376375
fileType: MapsType,
377-
readCloser: ioutil.NopCloser(bytes.NewReader([]byte("hello world"))),
376+
readCloser: io.NopCloser(bytes.NewReader([]byte("hello world"))),
378377
file: "newfile.map",
379378
want: filepath.Join(dirWithoutFile, "newfile.map"),
380379
wantErr: false,

test/tcp_check_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package test
1717

1818
import (
1919
"fmt"
20-
"io/ioutil"
2120
"testing"
2221

2322
"github.com/google/go-cmp/cmp"
@@ -40,18 +39,6 @@ func tcpCheckExpectation() map[string]models.TCPChecks {
4039
return res
4140
}
4241

43-
func generateTCPCheckConfig(config string) (string, error) {
44-
f, err := ioutil.TempFile("/tmp", "tcp_check")
45-
if err != nil {
46-
return "", err
47-
}
48-
err = prepareTestFile(config, f.Name())
49-
if err != nil {
50-
return "", err
51-
}
52-
return f.Name(), nil
53-
}
54-
5542
func (self Counter) current() int64 {
5643
return self.count
5744
}

test/userlist_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,11 @@
1616
package test
1717

1818
import (
19-
"io/ioutil"
2019
"testing"
2120

2221
"github.com/haproxytech/client-native/v6/models"
2322
)
2423

25-
func generateUserListConfig(config string) (string, error) {
26-
f, err := ioutil.TempFile("/tmp", "userlist")
27-
if err != nil {
28-
return "", err
29-
}
30-
err = prepareTestFile(config, f.Name())
31-
if err != nil {
32-
return "", err
33-
}
34-
return f.Name(), nil
35-
}
36-
3724
func TestUserList(t *testing.T) {
3825
config := `# _version=1
3926
global

test/version_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
package test
1717

1818
import (
19-
"io/ioutil"
19+
"os"
2020
"testing"
2121

2222
"github.com/stretchr/testify/assert"
2323
"github.com/stretchr/testify/require"
2424
)
2525

2626
func generateConfig(config string) (string, error) {
27-
f, err := ioutil.TempFile("/tmp", "version")
27+
f, err := os.CreateTemp("/tmp", "version")
2828
if err != nil {
2929
return "", err
3030
}

0 commit comments

Comments
 (0)