(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestLexicalRelativePath(t *testing.T) { |
| 10 | tests := []struct { |
| 11 | name string |
| 12 | cwdPath string |
| 13 | modPath string |
| 14 | expected string |
| 15 | wantErr bool |
| 16 | }{ |
| 17 | { |
| 18 | name: "Simple relative path", |
| 19 | cwdPath: "/home/user", |
| 20 | modPath: "/home/user/project", |
| 21 | expected: "project", |
| 22 | }, |
| 23 | { |
| 24 | name: "Parent directory", |
| 25 | cwdPath: "/home/user/project", |
| 26 | modPath: "/home/user", |
| 27 | expected: "..", |
| 28 | }, |
| 29 | { |
| 30 | name: "Same directory", |
| 31 | cwdPath: "/home/user", |
| 32 | modPath: "/home/user", |
| 33 | expected: ".", |
| 34 | }, |
| 35 | { |
| 36 | name: "Auth Sock", |
| 37 | cwdPath: "/Users/user/project", |
| 38 | modPath: "/Users/user/.ssh/auth.sock", |
| 39 | expected: "../.ssh/auth.sock", |
| 40 | }, |
| 41 | { |
| 42 | name: "Auth Sock", |
| 43 | cwdPath: "/Users/user/project", |
| 44 | modPath: "/Users/user/./.1password/agent.sock", |
| 45 | expected: "../.1password/agent.sock", |
| 46 | }, |
| 47 | { |
| 48 | name: "Windows style paths", |
| 49 | cwdPath: `C:\Users\user`, |
| 50 | modPath: `C:\Users\user\project`, |
| 51 | expected: "project", |
| 52 | }, |
| 53 | { |
| 54 | name: "Windows different drives", |
| 55 | cwdPath: `C:\Users\user`, |
| 56 | modPath: `D:\Projects\myproject`, |
| 57 | wantErr: true, |
| 58 | }, |
| 59 | { |
| 60 | name: "Windows UNC paths", |
| 61 | cwdPath: `\\server\share\folder`, |
| 62 | modPath: `\\server\share\folder\project`, |
| 63 | expected: "project", |
| 64 | }, |
| 65 | { |
| 66 | name: "Mixed slashes", |
nothing calls this directly
no test coverage detected