~samwhited/xmpp

40815eb0d1793e6abd391bf482fb4f7fad2b963a — Sam Whited 5 years ago eafe42e
Fix tests that broke due to XML header changes
2 files changed, 7 insertions(+), 5 deletions(-)

M stream.go
M stream_test.go
M stream.go => stream.go +5 -2
@@ 17,6 17,10 @@ import (
	"mellium.im/xmpp/streamerror"
)

const (
	xmlHeader = `<?xml version="1.0" encoding="UTF-8"?>`
)

const streamIDLength = 16

// SessionState represents the current state of an XMPP session. For a


@@ 122,8 126,7 @@ func sendNewStream(w io.Writer, cfg *Config, id string) error {
	}

	_, err := fmt.Fprintf(w,
		xml.Header[0:len(xml.Header)-1]+
			`<stream:stream%sto='%s' from='%s' version='%s' xml:lang='%s' xmlns='%s' xmlns:stream='http://etherx.jabber.org/streams'>`,
		xmlHeader+`<stream:stream%sto='%s' from='%s' version='%s' xml:lang='%s' xmlns='%s' xmlns:stream='http://etherx.jabber.org/streams'>`,
		id,
		cfg.Location.String(),
		cfg.Origin.String(),

M stream_test.go => stream_test.go +2 -3
@@ 6,7 6,6 @@ package xmpp

import (
	"bytes"
	"encoding/xml"
	"fmt"
	"io"
	"strings"


@@ 39,10 38,10 @@ func TestSendNewS2S(t *testing.T) {
			err := sendNewStream(&b, config, ids)

			str := b.String()
			if !strings.HasPrefix(str, xml.Header) {
			if !strings.HasPrefix(str, xmlHeader) {
				t.Errorf("Expected string to start with XML header but got: %s", str)
			}
			str = strings.TrimPrefix(str, xml.Header)
			str = strings.TrimPrefix(str, xmlHeader)

			switch {
			case err != tc.err: