// Copyright 2016 Sam Whited. // Use of this source code is governed by the BSD 2-clause license that can be // found in the LICENSE file. package internal import ( "encoding/xml" "testing" ) var ( boshLink = Link{Rel: "urn:xmpp:alt-connections:xbosh", Href: "https://web.example.com:5280/bosh"} wsLink = Link{Rel: "urn:xmpp:alt-connections:websocket", Href: "wss://web.example.com:443/ws"} ) func TestUnmarshalWellKnownXML(t *testing.T) { hostMeta := []byte(` `) var xrd XRD if err := xml.Unmarshal(hostMeta, &xrd); err != nil { t.Error(err) } switch { case len(xrd.Links) != 2: t.Errorf("Expected 2 links in xrd unmarshal output, but found %d", len(xrd.Links)) case xrd.Links[0] != boshLink: t.Errorf("Expected %v, but got %v", boshLink, xrd.Links[0]) case xrd.Links[1] != wsLink: t.Errorf("Expected %v, but got %v", wsLink, xrd.Links[1]) } }