chore(all): remove deprecated io/ioutil import
This commit is contained in:
@@ -2,7 +2,6 @@ package openvpn
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -39,7 +38,7 @@ func writeIfDifferent(path, content string, puid, pgid int) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if writeData {
|
if writeData {
|
||||||
err = ioutil.WriteFile(path, []byte(content), perm)
|
err = os.WriteFile(path, []byte(content), perm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("writing file: %w", err)
|
return fmt.Errorf("writing file: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package pprof
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@@ -96,7 +96,7 @@ func Test_Server(t *testing.T) {
|
|||||||
assert.Equalf(t, http.StatusOK, httpResult.response.StatusCode,
|
assert.Equalf(t, http.StatusOK, httpResult.response.StatusCode,
|
||||||
"unexpected status code for URL %s: %s", httpResult.url, http.StatusText(httpResult.response.StatusCode))
|
"unexpected status code for URL %s: %s", httpResult.url, http.StatusText(httpResult.response.StatusCode))
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(httpResult.response.Body)
|
b, err := io.ReadAll(httpResult.response.Body)
|
||||||
require.NoErrorf(t, err, "unexpected error for URL %s: %s", httpResult.url, err)
|
require.NoErrorf(t, err, "unexpected error for URL %s: %s", httpResult.url, err)
|
||||||
assert.NotEmptyf(t, b, "response body is empty for URL %s", httpResult.url)
|
assert.NotEmptyf(t, b, "response body is empty for URL %s", httpResult.url)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -32,11 +31,11 @@ func Test_fetchAPI(t *testing.T) {
|
|||||||
},
|
},
|
||||||
"no server": {
|
"no server": {
|
||||||
responseStatus: http.StatusOK,
|
responseStatus: http.StatusOK,
|
||||||
responseBody: ioutil.NopCloser(strings.NewReader(`{}`)),
|
responseBody: io.NopCloser(strings.NewReader(`{}`)),
|
||||||
},
|
},
|
||||||
"success": {
|
"success": {
|
||||||
responseStatus: http.StatusOK,
|
responseStatus: http.StatusOK,
|
||||||
responseBody: ioutil.NopCloser(strings.NewReader(`{"servers":[
|
responseBody: io.NopCloser(strings.NewReader(`{"servers":[
|
||||||
{"country":"Country1","city":"City A","isp":"xyz","is_active":true,"hostnames":{"openvpn":"hosta"}},
|
{"country":"Country1","city":"City A","isp":"xyz","is_active":true,"hostnames":{"openvpn":"hosta"}},
|
||||||
{"country":"Country2","city":"City B","isp":"abc","is_active":false,"hostnames":{"openvpn":"hostb"}}
|
{"country":"Country2","city":"City B","isp":"abc","is_active":false,"hostnames":{"openvpn":"hostb"}}
|
||||||
]}`)),
|
]}`)),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package updater
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -145,7 +145,7 @@ func Test_Updater_GetServers(t *testing.T) {
|
|||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: testCase.responseStatus,
|
StatusCode: testCase.responseStatus,
|
||||||
Status: http.StatusText(testCase.responseStatus),
|
Status: http.StatusText(testCase.responseStatus),
|
||||||
Body: ioutil.NopCloser(strings.NewReader(testCase.responseBody)),
|
Body: io.NopCloser(strings.NewReader(testCase.responseBody)),
|
||||||
}, nil
|
}, nil
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package updater
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -41,7 +40,7 @@ func Test_fetchServers(t *testing.T) {
|
|||||||
ctx: context.Background(),
|
ctx: context.Background(),
|
||||||
responseStatus: http.StatusOK,
|
responseStatus: http.StatusOK,
|
||||||
//nolint:lll
|
//nolint:lll
|
||||||
responseBody: ioutil.NopCloser(strings.NewReader(`
|
responseBody: io.NopCloser(strings.NewReader(`
|
||||||
<div>
|
<div>
|
||||||
<table id="location-table">
|
<table id="location-table">
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -34,7 +33,7 @@ func Test_addServersFromAPI(t *testing.T) {
|
|||||||
"existinghost": {Hostname: "existinghost"},
|
"existinghost": {Hostname: "existinghost"},
|
||||||
},
|
},
|
||||||
responseStatus: http.StatusOK,
|
responseStatus: http.StatusOK,
|
||||||
responseBody: ioutil.NopCloser(strings.NewReader(`[
|
responseBody: io.NopCloser(strings.NewReader(`[
|
||||||
{"connectionName":"host1","region":"region1","country":"country1","location":"location1"},
|
{"connectionName":"host1","region":"region1","country":"country1","location":"location1"},
|
||||||
{"connectionName":"host2","region":"region2","country":"country1","location":"location2"}
|
{"connectionName":"host2","region":"region2","country":"country1","location":"location2"}
|
||||||
]`)),
|
]`)),
|
||||||
@@ -111,12 +110,12 @@ func Test_fetchAPI(t *testing.T) {
|
|||||||
},
|
},
|
||||||
"no server": {
|
"no server": {
|
||||||
responseStatus: http.StatusOK,
|
responseStatus: http.StatusOK,
|
||||||
responseBody: ioutil.NopCloser(strings.NewReader(`[]`)),
|
responseBody: io.NopCloser(strings.NewReader(`[]`)),
|
||||||
data: []serverData{},
|
data: []serverData{},
|
||||||
},
|
},
|
||||||
"success": {
|
"success": {
|
||||||
responseStatus: http.StatusOK,
|
responseStatus: http.StatusOK,
|
||||||
responseBody: ioutil.NopCloser(strings.NewReader(`[
|
responseBody: io.NopCloser(strings.NewReader(`[
|
||||||
{"connectionName":"host1","region":"region1","country":"country1","location":"location1"},
|
{"connectionName":"host1","region":"region1","country":"country1","location":"location1"},
|
||||||
{"connectionName":"host2","region":"region2","country":"country1","location":"location2"}
|
{"connectionName":"host2","region":"region2","country":"country1","location":"location2"}
|
||||||
]`)),
|
]`)),
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package updater
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -43,7 +42,7 @@ func Test_fetchServers(t *testing.T) {
|
|||||||
"success": {
|
"success": {
|
||||||
ctx: context.Background(),
|
ctx: context.Background(),
|
||||||
responseStatus: http.StatusOK,
|
responseStatus: http.StatusOK,
|
||||||
responseBody: ioutil.NopCloser(strings.NewReader(`
|
responseBody: io.NopCloser(strings.NewReader(`
|
||||||
<div class="blk blk--white locations-list">
|
<div class="blk blk--white locations-list">
|
||||||
<div class="blk__i">
|
<div class="blk__i">
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package html
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -59,7 +58,7 @@ func Test_Fetch(t *testing.T) {
|
|||||||
url: "https://example.com/path",
|
url: "https://example.com/path",
|
||||||
responseStatus: http.StatusOK,
|
responseStatus: http.StatusOK,
|
||||||
rootNode: parseTestHTML(t, "some body"),
|
rootNode: parseTestHTML(t, "some body"),
|
||||||
responseBody: ioutil.NopCloser(strings.NewReader("some body")),
|
responseBody: io.NopCloser(strings.NewReader("some body")),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user