2018-01-25 08:04:19 -08:00
|
|
|
package xmpp // import "fluux.io/xmpp"
|
2018-01-25 02:00:20 -08:00
|
|
|
|
|
|
|
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))
|
|
|
|
}
|
|
|
|
}
|