github.com/TeaOSLab/EdgeNode@v1.3.8/internal/utils/fs/locker_test.go (about) 1 // Copyright 2023 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . 2 3 package fsutils_test 4 5 import ( 6 "github.com/TeaOSLab/EdgeNode/internal/utils/fs" 7 "testing" 8 ) 9 10 func TestLocker_Lock(t *testing.T) { 11 var path = "/tmp/file-test" 12 var locker = fsutils.NewLocker(path) 13 err := locker.Lock() 14 if err != nil { 15 t.Fatal(err) 16 } 17 _ = locker.Release() 18 19 var locker2 = fsutils.NewLocker(path) 20 err = locker2.Lock() 21 if err != nil { 22 t.Fatal(err) 23 } 24 }