| 1 | package lockingscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/ |
| 2 | |
| 3 | import ( |
| 4 | "osscip-go gomod github.com/golang/go/src go1.25.0 os/" |
| 5 | "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 6 | |
| 7 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/" |
| 8 | ) |
| 9 | |
| 10 | func TestLockCachescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/TestLockCache().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 11 | var err error |
| 12 | |
| 13 | tmpf, err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.CreateTempscip-go gomod github.com/golang/go/src go1.25.0 os/CreateTemp().("", "testCacheLock") |
| 14 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, err) |
| 15 | defer func() { |
| 16 | osscip-go gomod github.com/golang/go/src go1.25.0 os/.Removescip-go gomod github.com/golang/go/src go1.25.0 os/Remove().(tmpf.Namescip-go gomod github.com/golang/go/src go1.25.0 os/File#Name().()) |
| 17 | }() |
| 18 | tmpf.Closescip-go gomod github.com/golang/go/src go1.25.0 os/File#Close().() |
| 19 | |
| 20 | cache, err := NewLockCachescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/NewLockCache().(tmpf.Namescip-go gomod github.com/golang/go/src go1.25.0 os/File#Name().()) |
| 21 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, err) |
| 22 | |
| 23 | testLocks := []Lockscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/Lock#{ |
| 24 | Lockscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/Lock#{Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/Lock#Path.: "folder/test1.dat", Idscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/Lock#Id.: "101"}, |
| 25 | Lockscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/Lock#{Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/Lock#Path.: "folder/test2.dat", Idscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/Lock#Id.: "102"}, |
| 26 | Lockscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/Lock#{Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/Lock#Path.: "root.dat", Idscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/Lock#Id.: "103"}, |
| 27 | } |
| 28 | |
| 29 | for _, l := range testLocks { |
| 30 | err = cache.Addscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/LockCache#Add().(l) |
| 31 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, err) |
| 32 | } |
| 33 | |
| 34 | locks := cache.Locksscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/LockCache#Locks().() |
| 35 | for _, l := range testLocks { |
| 36 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Contains().(t, locks, l) |
| 37 | } |
| 38 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, len(testLocks), len(locks)) |
| 39 | |
| 40 | err = cache.RemoveByPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/LockCache#RemoveByPath().("folder/test2.dat") |
| 41 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, err) |
| 42 | |
| 43 | locks = cache.Locksscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/LockCache#Locks().() |
| 44 | // delete item 1 from test locls |
| 45 | testLocks = append(testLocks[:1], testLocks[2:]...) |
| 46 | for _, l := range testLocks { |
| 47 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Contains().(t, locks, l) |
| 48 | } |
| 49 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, len(testLocks), len(locks)) |
| 50 | |
| 51 | err = cache.RemoveByIdscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/LockCache#RemoveById().("101") |
| 52 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, err) |
| 53 | |
| 54 | locks = cache.Locksscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/locking`/LockCache#Locks().() |
| 55 | testLocks = testLocks[1:] |
| 56 | for _, l := range testLocks { |
| 57 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Contains().(t, locks, l) |
| 58 | } |
| 59 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, len(testLocks), len(locks)) |
| 60 | } |