~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/gopkg.in/juju/charmstore.v5-unstable/internal/router/util_test.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
        "net/url"
12
12
        "strings"
13
13
 
 
14
        jujutesting "github.com/juju/testing"
14
15
        jc "github.com/juju/testing/checkers"
15
16
        gc "gopkg.in/check.v1"
16
17
        "gopkg.in/errgo.v1"
18
19
        "gopkg.in/juju/charmstore.v5-unstable/internal/router"
19
20
)
20
21
 
21
 
type utilSuite struct{}
 
22
type utilSuite struct {
 
23
        jujutesting.LoggingSuite
 
24
}
22
25
 
23
26
var _ = gc.Suite(&utilSuite{})
24
27
var relativeURLTests = []struct {
47
50
        target: "/bar",
48
51
        expect: "../bar",
49
52
}, {
 
53
        base:   "/bar",
 
54
        target: "/foo/",
 
55
        expect: "foo/",
 
56
}, {
50
57
        base:   "/foo/",
51
58
        target: "/bar/",
52
59
        expect: "../bar/",
97
104
}, {
98
105
        base:   "/foo/bar/",
99
106
        target: "/foo/bar/",
100
 
        expect: "",
 
107
        expect: ".",
101
108
}, {
102
109
        base:   "/foo/bar",
103
110
        target: "/foo/bar",
105
112
}, {
106
113
        base:   "/foo/bar/",
107
114
        target: "/foo/bar/",
108
 
        expect: "",
 
115
        expect: ".",
 
116
}, {
 
117
        base:   "/foo/bar",
 
118
        target: "/foo/",
 
119
        expect: ".",
 
120
}, {
 
121
        base:   "/foo",
 
122
        target: "/",
 
123
        expect: ".",
 
124
}, {
 
125
        base:   "/foo/",
 
126
        target: "/",
 
127
        expect: "../",
 
128
}, {
 
129
        base:   "/foo/bar",
 
130
        target: "/",
 
131
        expect: "../",
 
132
}, {
 
133
        base:   "/foo/bar/",
 
134
        target: "/",
 
135
        expect: "../../",
109
136
}}
110
137
 
111
138
func (*utilSuite) TestRelativeURL(c *gc.C) {
116
143
                        baseURL := &url.URL{Path: test.base}
117
144
                        expectURL := &url.URL{Path: test.expect}
118
145
                        targetURL := baseURL.ResolveReference(expectURL)
119
 
                        c.Check(targetURL.Path, gc.Equals, test.target, gc.Commentf("resolve reference failure"))
 
146
                        c.Check(targetURL.Path, gc.Equals, test.target, gc.Commentf("resolve reference failure (%q + %q != %q)", test.base, test.expect, test.target))
120
147
                }
121
148
 
122
149
                result, err := router.RelativeURLPath(test.base, test.target)