aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2023-03-01 09:34:13 +0100
committerBjørn Erik Pedersen <[email protected]>2023-03-01 16:28:43 +0100
commita669467d98f54860fa7f06fbfdd1d8fdc98773fd (patch)
tree29c6444f8489006af9770e089adec3f1c4a3c081
parentd453c12742e992d672fcf3e61b7a5ed35391c4b0 (diff)
downloadhugo-a669467d98f54860fa7f06fbfdd1d8fdc98773fd.tar.gz
hugo-a669467d98f54860fa7f06fbfdd1d8fdc98773fd.zip
Misc ioutil deprecation adjustments
To make the tests pass. * Replace io => os.ReadFile in magefile.go * Adjust failing image test vs fs.DirEntry * Adjust poller test See #10732
-rw-r--r--magefile.go3
-rw-r--r--resources/image_test.go9
-rw-r--r--watcher/filenotify/poller_test.go6
3 files changed, 15 insertions, 3 deletions
diff --git a/magefile.go b/magefile.go
index f00964cf7..bd9c5b830 100644
--- a/magefile.go
+++ b/magefile.go
@@ -7,7 +7,6 @@ import (
"bytes"
"errors"
"fmt"
- "io"
"os"
"path"
"path/filepath"
@@ -298,7 +297,7 @@ func TestCoverHTML() error {
if err := sh.Run(goexe, "test", "-coverprofile="+cover, "-covermode=count", pkg); err != nil {
return err
}
- b, err := io.ReadFile(cover)
+ b, err := os.ReadFile(cover)
if err != nil {
if os.IsNotExist(err) {
continue
diff --git a/resources/image_test.go b/resources/image_test.go
index e9d875ec0..e5d0fd620 100644
--- a/resources/image_test.go
+++ b/resources/image_test.go
@@ -18,6 +18,7 @@ import (
"fmt"
"image"
"image/gif"
+ "io/fs"
"math/big"
"math/rand"
"os"
@@ -56,6 +57,14 @@ var eq = qt.CmpEquals(
cmp.Comparer(func(p1, p2 os.FileInfo) bool {
return p1.Name() == p2.Name() && p1.Size() == p2.Size() && p1.IsDir() == p2.IsDir()
}),
+ cmp.Comparer(func(d1, d2 fs.DirEntry) bool {
+ p1, err1 := d1.Info()
+ p2, err2 := d2.Info()
+ if err1 != nil || err2 != nil {
+ return false
+ }
+ return p1.Name() == p2.Name() && p1.Size() == p2.Size() && p1.IsDir() == p2.IsDir()
+ }),
cmp.Comparer(func(p1, p2 *genericResource) bool { return p1 == p2 }),
cmp.Comparer(func(m1, m2 media.Type) bool {
return m1.Type() == m2.Type()
diff --git a/watcher/filenotify/poller_test.go b/watcher/filenotify/poller_test.go
index 336314fff..7416f793a 100644
--- a/watcher/filenotify/poller_test.go
+++ b/watcher/filenotify/poller_test.go
@@ -34,10 +34,14 @@ func TestPollerAddRemove(t *testing.T) {
c.Assert(w.Add("foo"), qt.Not(qt.IsNil))
c.Assert(w.Remove("foo"), qt.Not(qt.IsNil))
- f, err := os.CreateTemp(t.TempDir(), "asdf")
+ f, err := os.CreateTemp("", "asdf")
if err != nil {
t.Fatal(err)
}
+ c.Cleanup(func() {
+ c.Assert(w.Close(), qt.IsNil)
+ os.Remove(f.Name())
+ })
c.Assert(w.Add(f.Name()), qt.IsNil)
c.Assert(w.Remove(f.Name()), qt.IsNil)