mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2024-12-17 14:02:04 -08:00
3b66e31888
Fixes #110
32 lines
739 B
Go
32 lines
739 B
Go
package stanza
|
|
|
|
import (
|
|
"encoding/xml"
|
|
"testing"
|
|
)
|
|
|
|
func TestErr_UnmarshalXML(t *testing.T) {
|
|
packet := `
|
|
<iq from='pubsub.example.com'
|
|
id='kj4vz31m'
|
|
to='romeo@example.net/foo'
|
|
type='error'>
|
|
<error type='wait'>
|
|
<resource-constraint
|
|
xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
|
|
<text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>System overloaded, please retry</text>
|
|
</error>
|
|
</iq>`
|
|
|
|
parsedIQ := IQ{}
|
|
data := []byte(packet)
|
|
if err := xml.Unmarshal(data, &parsedIQ); err != nil {
|
|
t.Errorf("Unmarshal(%s) returned error", data)
|
|
}
|
|
|
|
xmppError := parsedIQ.Error
|
|
if xmppError.Text != "System overloaded, please retry" {
|
|
t.Errorf("Could not extract error text: '%s'", xmppError.Text)
|
|
}
|
|
}
|