MCPcopy Create free account
hub / github.com/cloudwan/gohan / TestFixRelativeURL

Function TestFixRelativeURL

schema/url_test.go:54–81  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

52}
53
54func 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}

Callers

nothing calls this directly

Calls 3

fixRelativeURLFunction · 0.85
FatalMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected