]> Sergey Matveev's repositories - btrtrc.git/blobdiff - metainfo/metainfo_test.go
chore: remove refs to deprecated io/ioutil
[btrtrc.git] / metainfo / metainfo_test.go
index 84aec2123f1adb9557d5cb85e96d261c24ffc427..335631f9850c7ba6b135612c38ed89958e48bfa9 100644 (file)
@@ -2,7 +2,6 @@ package metainfo
 
 import (
        "io"
-       "io/ioutil"
        "os"
        "path"
        "path/filepath"
@@ -68,7 +67,7 @@ func TestNumPieces(t *testing.T) {
                        PieceLength: _case.PieceLength,
                }
                err := info.GeneratePieces(func(fi FileInfo) (io.ReadCloser, error) {
-                       return ioutil.NopCloser(missinggo.ZeroReader), nil
+                       return io.NopCloser(missinggo.ZeroReader), nil
                })
                assert.NoError(t, err)
                assert.EqualValues(t, _case.NumPieces, info.NumPieces())
@@ -85,9 +84,7 @@ func touchFile(path string) (err error) {
 }
 
 func TestBuildFromFilePathOrder(t *testing.T) {
-       td, err := ioutil.TempDir("", "anacrolix")
-       require.NoError(t, err)
-       defer os.RemoveAll(td)
+       td := t.TempDir()
        require.NoError(t, touchFile(filepath.Join(td, "b")))
        require.NoError(t, touchFile(filepath.Join(td, "a")))
        info := Info{
@@ -155,3 +152,11 @@ func TestStringCreationDate(t *testing.T) {
        var mi MetaInfo
        assert.NoError(t, bencode.Unmarshal([]byte("d13:creation date23:29.03.2018 22:18:14 UTC4:infodee"), &mi))
 }
+
+// See https://github.com/anacrolix/torrent/issues/843.
+func TestUnmarshalEmptyStringNodes(t *testing.T) {
+       var mi MetaInfo
+       c := qt.New(t)
+       err := bencode.Unmarshal([]byte("d5:nodes0:e"), &mi)
+       c.Assert(err, qt.IsNil)
+}