/usr/share/gocode/src/github.com/tent/http-link-go/link_test.go is in golang-github-tent-http-link-go-dev 0.0~git20130702.0.ac974c6-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | package link
import (
"testing"
. "gopkg.in/check.v1"
)
// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) { TestingT(t) }
type LinkSuite struct{}
var _ = Suite(&LinkSuite{})
// TODO: add more tests
var linkParseTests = []struct {
in string
out []Link
}{
{
"<http://example.com/TheBook/chapter2>; rel=\"previous\";\n title=\"previous chapter\"",
[]Link{{URI: "http://example.com/TheBook/chapter2", Rel: "previous", Params: map[string]string{"title": "previous chapter"}}},
},
{
"</TheBook/chapter2>;\n rel=\"previous\"; title*=UTF-8'de'letztes%20Kapitel,\n </TheBook/chapter4>;\n rel=\"next\"; title*=UTF-8'de'n%c3%a4chstes%20Kapitel",
[]Link{
{URI: "/TheBook/chapter2", Rel: "previous", Params: map[string]string{"title*": "UTF-8'de'letztes%20Kapitel"}},
{URI: "/TheBook/chapter4", Rel: "next", Params: map[string]string{"title*": "UTF-8'de'n%c3%a4chstes%20Kapitel"}},
},
},
}
func (s *LinkSuite) TestLinkParsing(c *C) {
for i, t := range linkParseTests {
res, err := Parse(t.in)
c.Assert(err, IsNil, Commentf("test %d", i))
c.Assert(res, DeepEquals, t.out, Commentf("test %d", i))
}
}
var linkFormatTests = []struct {
in []Link
out string
}{
{
[]Link{{URI: "/a", Rel: "foo", Params: map[string]string{"a": "b", "c": "d"}}},
`</a>; rel="foo"; a="b"; c="d"`,
},
{
[]Link{
{URI: "/b", Rel: "foo", Params: map[string]string{"a": "b", "c": "d"}},
{URI: "/a", Rel: "foo", Params: map[string]string{"a": "b", "c": "d"}}},
`</b>; rel="foo"; a="b"; c="d", </a>; rel="foo"; a="b"; c="d"`,
},
}
func (s *LinkSuite) TestLinkGeneration(c *C) {
for i, t := range linkFormatTests {
res := Format(t.in)
cm := Commentf("test %d", i)
c.Assert(res, Equals, t.out, cm)
parsed, err := Parse(res)
c.Assert(err, IsNil, cm)
c.Assert(parsed, DeepEquals, t.in, cm)
}
}
|