2
0
mirror of https://github.com/FluuxIO/go-xmpp synced 2024-11-17 15:29:37 +00:00
go-xmpp/presence_test.go
Mickael Remond 5eae7f4ef7
Move project to gosrc.io/xmpp
The URL will be more permanent as this is a place we dedicate as short URL for our go projects.
2018-12-26 18:50:01 +01:00

28 lines
616 B
Go

package xmpp // import "gosrc.io/xmpp"
import (
"encoding/xml"
"testing"
"github.com/google/go-cmp/cmp"
)
func TestGeneratePresence(t *testing.T) {
presence := NewPresence("admin@localhost", "test@localhost", "1", "en")
presence.Show = "chat"
data, err := xml.Marshal(presence)
if err != nil {
t.Errorf("cannot marshal xml structure")
}
parsedPresence := Presence{}
if err = xml.Unmarshal(data, &parsedPresence); err != nil {
t.Errorf("Unmarshal(%s) returned error", data)
}
if !xmlEqual(parsedPresence, presence) {
t.Errorf("non matching items\n%s", cmp.Diff(parsedPresence, presence))
}
}