1 Star 0 Fork 1

lsj/go-torrent

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
client-nowasm_test.go 1.38 KB
一键复制 编辑 原始数据 按行查看 历史
afjoseph 提交于 2021-10-28 10:53 . Revert "Remove old-style build tags"
//go:build !wasm
// +build !wasm
package torrent
import (
"os"
"testing"
"github.com/anacrolix/torrent/internal/testutil"
"github.com/anacrolix/torrent/storage"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestBoltPieceCompletionClosedWhenClientClosed(t *testing.T) {
cfg := TestingConfig(t)
pc, err := storage.NewBoltPieceCompletion(cfg.DataDir)
require.NoError(t, err)
ci := storage.NewFileWithCompletion(cfg.DataDir, pc)
defer ci.Close()
cfg.DefaultStorage = ci
cl, err := NewClient(cfg)
require.NoError(t, err)
cl.Close()
// And again, https://github.com/anacrolix/torrent/issues/158
cl, err = NewClient(cfg)
require.NoError(t, err)
cl.Close()
}
func TestIssue335(t *testing.T) {
dir, mi := testutil.GreetingTestTorrent()
defer os.RemoveAll(dir)
cfg := TestingConfig(t)
cfg.Seed = false
cfg.Debug = true
cfg.DataDir = dir
comp, err := storage.NewBoltPieceCompletion(dir)
require.NoError(t, err)
defer comp.Close()
cfg.DefaultStorage = storage.NewMMapWithCompletion(dir, comp)
cl, err := NewClient(cfg)
require.NoError(t, err)
defer cl.Close()
tor, new, err := cl.AddTorrentSpec(TorrentSpecFromMetaInfo(mi))
require.NoError(t, err)
assert.True(t, new)
require.True(t, cl.WaitAll())
tor.Drop()
_, new, err = cl.AddTorrentSpec(TorrentSpecFromMetaInfo(mi))
require.NoError(t, err)
assert.True(t, new)
require.True(t, cl.WaitAll())
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/leesj/go-torrent.git
git@gitee.com:leesj/go-torrent.git
leesj
go-torrent
go-torrent
master

搜索帮助