go-xmpp/control_test.go

27 lines
647 B
Go
Raw Normal View History

package xmpp // import "gosrc.io/xmpp"
import (
"encoding/xml"
"testing"
)
func TestControlSet(t *testing.T) {
packet := `
<iq to='test@localhost/jukebox' from='admin@localhost/mbp' type='set' id='2'>
<set xmlns='urn:xmpp:iot:control' xml:lang='en'>
<string name='action' value='play'/>
<string name='url' value='https://soundcloud.com/radiohead/spectre'/>
</set>
</iq>`
parsedIQ := IQ{}
data := []byte(packet)
if err := xml.Unmarshal(data, &parsedIQ); err != nil {
t.Errorf("Unmarshal(%s) returned error", data)
}
2019-06-04 15:04:25 +00:00
if cs, ok := parsedIQ.Payload[0].(*ControlSet); !ok {
t.Errorf("Paylod is not an iot control set: %v", cs)
}
}