1 Star 0 Fork 0

chirdxing/fsnotify

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
backend_fen_test.go 1.21 KB
一键复制 编辑 原始数据 按行查看 历史
//go:build solaris
package fsnotify
import (
"fmt"
"strings"
"testing"
)
func TestRemoveState(t *testing.T) {
var (
tmp = t.TempDir()
dir = join(tmp, "dir")
file = join(dir, "file")
)
mkdir(t, dir)
touch(t, file)
w := newWatcher(t, tmp)
addWatch(t, w, tmp)
addWatch(t, w, file)
check := func(wantDirs, wantFiles int) {
t.Helper()
if len(w.b.(*fen).watches) != wantFiles {
var d []string
for k, v := range w.b.(*fen).watches {
d = append(d, fmt.Sprintf("%#v = %#v", k, v))
}
t.Errorf("unexpected number of entries in w.watches (have %d, want %d):\n%v",
len(w.b.(*fen).watches), wantFiles, strings.Join(d, "\n"))
}
if len(w.b.(*fen).dirs) != wantDirs {
var d []string
for k, v := range w.b.(*fen).dirs {
d = append(d, fmt.Sprintf("%#v = %#v", k, v))
}
t.Errorf("unexpected number of entries in w.dirs (have %d, want %d):\n%v",
len(w.b.(*fen).dirs), wantDirs, strings.Join(d, "\n"))
}
}
check(1, 1)
// Shouldn't change internal state.
if err := w.Add("/path-doesnt-exist"); err == nil {
t.Fatal(err)
}
check(1, 1)
if err := w.Remove(file); err != nil {
t.Fatal(err)
}
check(1, 0)
if err := w.Remove(tmp); err != nil {
t.Fatal(err)
}
check(0, 0)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chirdxing/fsnotify.git
git@gitee.com:chirdxing/fsnotify.git
chirdxing
fsnotify
fsnotify
main

搜索帮助