| 11 | ) |
| 12 | |
| 13 | func TestPathLockBasic(t *testing.T) { |
| 14 | pl := NewLocker() |
| 15 | |
| 16 | cwd, err := os.Getwd() |
| 17 | if err != nil { |
| 18 | t.Fatalf("Could not get working directory: %v", err) |
| 19 | } |
| 20 | |
| 21 | for ti, tc := range []struct { |
| 22 | name string |
| 23 | path1 string |
| 24 | path2 string |
| 25 | }{ |
| 26 | { |
| 27 | name: "(Abs) Blocks a Lock call for the same path /a/b/c", |
| 28 | path1: "/a/b/c", |
| 29 | path2: "/a/b/c", |
| 30 | }, |
| 31 | { |
| 32 | name: "(Abs) Blocks a Lock call for path /a/b/c/d", |
| 33 | path1: "/a/b/c", |
| 34 | path2: "/a/b/c/d", |
| 35 | }, |
| 36 | { |
| 37 | name: "(Abs) Blocks a Lock call for path /a/b", |
| 38 | path1: "/a/b/c", |
| 39 | path2: "/a/b", |
| 40 | }, |
| 41 | { |
| 42 | name: "(Abs) Blocks a Lock call for path /a", |
| 43 | path1: "/a/b/c", |
| 44 | path2: "/a", |
| 45 | }, |
| 46 | { |
| 47 | name: "(Rel) Blocks a Lock call for the same path a/b/c", |
| 48 | path1: "a/b/c", |
| 49 | path2: "a/b/c", |
| 50 | }, |
| 51 | { |
| 52 | name: "(Rel) Blocks a Lock call for path a/b/c/d", |
| 53 | path1: "a/b/c", |
| 54 | path2: "a/b/c/d", |
| 55 | }, |
| 56 | { |
| 57 | name: "(Rel) Blocks a Lock call for path a/b", |
| 58 | path1: "a/b/c", |
| 59 | path2: "a/b", |
| 60 | }, |
| 61 | { |
| 62 | name: "(Rel) Blocks a Lock call for path a", |
| 63 | path1: "a/b/c", |
| 64 | path2: "a", |
| 65 | }, |
| 66 | { |
| 67 | name: "(Mix Abs/Rel) Blocks a Lock call for the same path a/b/c", |
| 68 | path1: filepath.Join(cwd, "a/b/c"), |
| 69 | path2: "a/b/c", |
| 70 | }, |