Skip to content

Commit 7315f12

Browse files
sbinetmattn
authored andcommitted
all: remove use of deprecated io/ioutil package
Signed-off-by: Sebastien Binet <[email protected]>
1 parent d8beb07 commit 7315f12

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

helper_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package mastodon
22

33
import (
4-
"io/ioutil"
4+
"io"
55
"net/http"
66
"os"
77
"strings"
@@ -39,7 +39,7 @@ func TestBase64Encode(t *testing.T) {
3939
if err != nil {
4040
t.Fatalf("should not be fail: %v", err)
4141
}
42-
_, err = ioutil.ReadAll(logo)
42+
_, err = io.ReadAll(logo)
4343
if err != nil {
4444
t.Fatalf("should not be fail: %v", err)
4545
}
@@ -72,7 +72,7 @@ func TestString(t *testing.T) {
7272

7373
func TestParseAPIError(t *testing.T) {
7474
// No api error.
75-
r := ioutil.NopCloser(strings.NewReader(`<html><head><title>404</title></head></html>`))
75+
r := io.NopCloser(strings.NewReader(`<html><head><title>404</title></head></html>`))
7676
err := parseAPIError("bad request", &http.Response{
7777
Status: "404 Not Found",
7878
StatusCode: http.StatusNotFound,
@@ -84,7 +84,7 @@ func TestParseAPIError(t *testing.T) {
8484
}
8585

8686
// With api error.
87-
r = ioutil.NopCloser(strings.NewReader(`{"error":"Record not found"}`))
87+
r = io.NopCloser(strings.NewReader(`{"error":"Record not found"}`))
8888
err = parseAPIError("bad request", &http.Response{
8989
Status: "404 Not Found",
9090
StatusCode: http.StatusNotFound,

status_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"context"
66
"fmt"
7-
"io/ioutil"
87
"net/http"
98
"net/http/httptest"
109
"os"
@@ -878,7 +877,7 @@ func TestUploadMedia(t *testing.T) {
878877
if writerAttachment.ID != "123" {
879878
t.Fatalf("want %q but %q", "123", attachment.ID)
880879
}
881-
bytes, err := ioutil.ReadFile("testdata/logo.png")
880+
bytes, err := os.ReadFile("testdata/logo.png")
882881
if err != nil {
883882
t.Fatalf("could not open file: %v", err)
884883
}

0 commit comments

Comments
 (0)