(t *testing.T)
| 52 | } |
| 53 | |
| 54 | func TestFixRelativeURL(t *testing.T) { |
| 55 | t.Parallel() |
| 56 | |
| 57 | const dir = "/home/test/me" |
| 58 | |
| 59 | data := []struct { |
| 60 | Rawurl string |
| 61 | Expected string |
| 62 | }{ |
| 63 | {"./foobar", "file:///home/test/me/foobar"}, |
| 64 | {"/foobar", "file:///foobar"}, |
| 65 | {"file://foobar", "file:///home/test/me/foobar"}, |
| 66 | {"file://./foobar", "file:///home/test/me/foobar"}, |
| 67 | {"file://../foobar", "file:///home/test/foobar"}, |
| 68 | {"file://../../foobar", "file:///home/foobar"}, |
| 69 | {"file:///home/foobar", "file:///home/foobar"}, |
| 70 | } |
| 71 | |
| 72 | for _, d := range data { |
| 73 | actual, err := fixRelativeURL(d.Rawurl, dir) |
| 74 | if err != nil { |
| 75 | t.Fatal(err) |
| 76 | } |
| 77 | if actual != d.Expected { |
| 78 | t.Error("Mismatch on", d, actual) |
| 79 | } |
| 80 | } |
| 81 | } |
nothing calls this directly
no test coverage detected