mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
* Remove `make updatedeps` from Travis build. We'll follow up with more specific plans around dependency updating in subsequent PRs. * Update all `make` targets to set `GO15VENDOREXPERIMENT=1` and to filter out `/vendor/` from `./...` where appropriate. * Temporarily remove `vet` from the `make test` target until we can figure out how to get it to not vet `vendor/`. (Initial experimentation failed to yield the proper incantation.) Everything is pinned to current master, with the exception of: * Azure/azure-sdk-for-go which is pinned before the breaking change today * aws/aws-sdk-go which is pinned to the most recent tag The documentation still needs to be updated, which we can do in a follow up PR. The goal here is to unblock release.
68 lines
1.8 KiB
Go
68 lines
1.8 KiB
Go
package link
|
|
|
|
import (
|
|
"testing"
|
|
|
|
. "launchpad.net/gocheck"
|
|
)
|
|
|
|
// 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)
|
|
}
|
|
}
|