2018-12-26 17:50:01 +00:00
|
|
|
package xmpp // import "gosrc.io/xmpp"
|
2018-02-13 22:04:13 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/xml"
|
|
|
|
"testing"
|
|
|
|
|
2018-12-26 18:10:30 +00:00
|
|
|
"gosrc.io/xmpp/iot"
|
2018-02-13 22:04:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
|
|
|
if cs, ok := parsedIQ.Payload[0].(*iot.ControlSet); !ok {
|
|
|
|
t.Errorf("Paylod is not an iot control set: %v", cs)
|
|
|
|
}
|
|
|
|
}
|