aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Zou Nengren <zouyee1989@gmail.com> 2021-10-13 15:30:31 +0800
committerGravatar GitHub <noreply@github.com> 2021-10-13 09:30:31 +0200
commit5191959bd7278b6ec990093ec708c262d7ef416e (patch)
tree0a48bb5bfd5f18673edee9ab7aa55497aa28eefb /test
parent44fcca0e0d67d66dee72ef00d389a16c2ff066a9 (diff)
downloadcoredns-5191959bd7278b6ec990093ec708c262d7ef416e.tar.gz
coredns-5191959bd7278b6ec990093ec708c262d7ef416e.tar.zst
coredns-5191959bd7278b6ec990093ec708c262d7ef416e.zip
cleanup deprecated package io/ioutil (#4920)
Signed-off-by: zounengren <zouyee1989@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/auto_test.go11
-rw-r--r--test/erratic_autopath_test.go5
-rw-r--r--test/file_reload_test.go4
-rw-r--r--test/metrics_test.go5
-rw-r--r--test/plugin_dnssec_test.go5
-rw-r--r--test/readme_test.go5
-rw-r--r--test/reload_test.go8
7 files changed, 19 insertions, 24 deletions
diff --git a/test/auto_test.go b/test/auto_test.go
index 1c4828b04..b80c334c5 100644
--- a/test/auto_test.go
+++ b/test/auto_test.go
@@ -1,7 +1,6 @@
package test
import (
- "io/ioutil"
"os"
"path/filepath"
"testing"
@@ -12,7 +11,7 @@ import (
func TestAuto(t *testing.T) {
t.Parallel()
- tmpdir, err := ioutil.TempDir(os.TempDir(), "coredns")
+ tmpdir, err := os.MkdirTemp(os.TempDir(), "coredns")
if err != nil {
t.Fatal(err)
}
@@ -42,7 +41,7 @@ func TestAuto(t *testing.T) {
}
// Write db.example.org to get example.org.
- if err = ioutil.WriteFile(filepath.Join(tmpdir, "db.example.org"), []byte(zoneContent), 0644); err != nil {
+ if err = os.WriteFile(filepath.Join(tmpdir, "db.example.org"), []byte(zoneContent), 0644); err != nil {
t.Fatal(err)
}
@@ -71,7 +70,7 @@ func TestAuto(t *testing.T) {
func TestAutoNonExistentZone(t *testing.T) {
t.Parallel()
- tmpdir, err := ioutil.TempDir(os.TempDir(), "coredns")
+ tmpdir, err := os.MkdirTemp(os.TempDir(), "coredns")
if err != nil {
t.Fatal(err)
}
@@ -110,7 +109,7 @@ func TestAutoNonExistentZone(t *testing.T) {
func TestAutoAXFR(t *testing.T) {
t.Parallel()
- tmpdir, err := ioutil.TempDir(os.TempDir(), "coredns")
+ tmpdir, err := os.MkdirTemp(os.TempDir(), "coredns")
if err != nil {
t.Fatal(err)
}
@@ -138,7 +137,7 @@ func TestAutoAXFR(t *testing.T) {
defer i.Stop()
// Write db.example.org to get example.org.
- if err = ioutil.WriteFile(filepath.Join(tmpdir, "db.example.org"), []byte(zoneContent), 0644); err != nil {
+ if err = os.WriteFile(filepath.Join(tmpdir, "db.example.org"), []byte(zoneContent), 0644); err != nil {
t.Fatal(err)
}
diff --git a/test/erratic_autopath_test.go b/test/erratic_autopath_test.go
index ef7729815..1c6364a09 100644
--- a/test/erratic_autopath_test.go
+++ b/test/erratic_autopath_test.go
@@ -1,7 +1,6 @@
package test
import (
- "io/ioutil"
"os"
"path/filepath"
"testing"
@@ -10,7 +9,7 @@ import (
)
func setupProxyTargetCoreDNS(t *testing.T, fn func(string)) {
- tmpdir, err := ioutil.TempDir(os.TempDir(), "coredns")
+ tmpdir, err := os.MkdirTemp(os.TempDir(), "coredns")
if err != nil {
t.Fatal(err)
}
@@ -24,7 +23,7 @@ google.com. IN A 172.217.25.110
`
path := filepath.Join(tmpdir, "file")
- if err = ioutil.WriteFile(path, []byte(content), 0644); err != nil {
+ if err = os.WriteFile(path, []byte(content), 0644); err != nil {
t.Fatalf("Could not write to temp file: %s", err)
}
defer os.Remove(path)
diff --git a/test/file_reload_test.go b/test/file_reload_test.go
index 69b9af5f6..254ef94bd 100644
--- a/test/file_reload_test.go
+++ b/test/file_reload_test.go
@@ -1,7 +1,7 @@
package test
import (
- "io/ioutil"
+ "os"
"testing"
"time"
@@ -45,7 +45,7 @@ func TestZoneReload(t *testing.T) {
}
// Remove RR from the Apex
- ioutil.WriteFile(name, []byte(exampleOrgUpdated), 0644)
+ os.WriteFile(name, []byte(exampleOrgUpdated), 0644)
time.Sleep(20 * time.Millisecond) // reload time, with some race insurance
diff --git a/test/metrics_test.go b/test/metrics_test.go
index 38092f009..66c21ba0c 100644
--- a/test/metrics_test.go
+++ b/test/metrics_test.go
@@ -1,7 +1,6 @@
package test
import (
- "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -69,7 +68,7 @@ func TestMetricsRefused(t *testing.T) {
}
func TestMetricsAuto(t *testing.T) {
- tmpdir, err := ioutil.TempDir(os.TempDir(), "coredns")
+ tmpdir, err := os.MkdirTemp(os.TempDir(), "coredns")
if err != nil {
t.Fatal(err)
}
@@ -95,7 +94,7 @@ func TestMetricsAuto(t *testing.T) {
defer i.Stop()
// Write db.example.org to get example.org.
- if err = ioutil.WriteFile(filepath.Join(tmpdir, "db.example.org"), []byte(zoneContent), 0644); err != nil {
+ if err = os.WriteFile(filepath.Join(tmpdir, "db.example.org"), []byte(zoneContent), 0644); err != nil {
t.Fatal(err)
}
time.Sleep(110 * time.Millisecond) // wait for it to be picked up
diff --git a/test/plugin_dnssec_test.go b/test/plugin_dnssec_test.go
index e6b22c119..48e032c51 100644
--- a/test/plugin_dnssec_test.go
+++ b/test/plugin_dnssec_test.go
@@ -1,7 +1,6 @@
package test
import (
- "io/ioutil"
"os"
"testing"
@@ -56,10 +55,10 @@ func TestLookupBalanceRewriteCacheDnssec(t *testing.T) {
}
func createKeyFile(t *testing.T) func() {
- ioutil.WriteFile(base+".key",
+ os.WriteFile(base+".key",
[]byte(`example.org. IN DNSKEY 256 3 13 tDyI0uEIDO4SjhTJh1AVTFBLpKhY3He5BdAlKztewiZ7GecWj94DOodg ovpN73+oJs+UfZ+p9zOSN5usGAlHrw==`),
0644)
- ioutil.WriteFile(base+".private",
+ os.WriteFile(base+".private",
[]byte(`Private-key-format: v1.3
Algorithm: 13 (ECDSAP256SHA256)
PrivateKey: HPmldSNfrkj/aDdUMFwuk/lgzaC5KIsVEG3uoYvF4pQ=
diff --git a/test/readme_test.go b/test/readme_test.go
index 4b721918b..bc79f7465 100644
--- a/test/readme_test.go
+++ b/test/readme_test.go
@@ -3,7 +3,6 @@ package test
import (
"bufio"
"fmt"
- "io/ioutil"
"os"
"path/filepath"
"strconv"
@@ -52,7 +51,7 @@ func TestReadme(t *testing.T) {
defer remove(contents)
middle := filepath.Join("..", "plugin")
- dirs, err := ioutil.ReadDir(middle)
+ dirs, err := os.ReadDir(middle)
if err != nil {
t.Fatalf("Could not read %s: %q", middle, err)
}
@@ -173,7 +172,7 @@ func sectionsFromReadme(readme string) error {
func create(c map[string]string) {
for name, content := range c {
- ioutil.WriteFile(name, []byte(content), 0644)
+ os.WriteFile(name, []byte(content), 0644)
}
}
diff --git a/test/reload_test.go b/test/reload_test.go
index 2880011aa..4c67b6711 100644
--- a/test/reload_test.go
+++ b/test/reload_test.go
@@ -3,7 +3,7 @@ package test
import (
"bytes"
"fmt"
- "io/ioutil"
+ "io"
"net/http"
"strings"
"testing"
@@ -105,7 +105,7 @@ func TestReloadMetricsHealth(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- ok, _ := ioutil.ReadAll(resp.Body)
+ ok, _ := io.ReadAll(resp.Body)
resp.Body.Close()
if string(ok) != http.StatusText(http.StatusOK) {
t.Errorf("Failed to receive OK, got %s", ok)
@@ -117,7 +117,7 @@ func TestReloadMetricsHealth(t *testing.T) {
t.Fatal(err)
}
const proc = "coredns_build_info"
- metrics, _ := ioutil.ReadAll(resp.Body)
+ metrics, _ := io.ReadAll(resp.Body)
if !bytes.Contains(metrics, []byte(proc)) {
t.Errorf("Failed to see %s in metric output", proc)
}
@@ -129,7 +129,7 @@ func collectMetricsInfo(addr string, procs ...string) error {
if err != nil {
return err
}
- metrics, _ := ioutil.ReadAll(resp.Body)
+ metrics, _ := io.ReadAll(resp.Body)
for _, p := range procs {
if !bytes.Contains(metrics, []byte(p)) {
return fmt.Errorf("failed to see %s in metric output \n%s", p, metrics)