mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2024-11-24 11:32:00 -08:00
5eae7f4ef7
The URL will be more permanent as this is a place we dedicate as short URL for our go projects.
29 lines
643 B
Go
29 lines
643 B
Go
package xmpp // import "gosrc.io/xmpp"
|
|
|
|
import (
|
|
"encoding/xml"
|
|
"testing"
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
)
|
|
|
|
func TestGenerateMessage(t *testing.T) {
|
|
message := NewMessage("chat", "admin@localhost", "test@localhost", "1", "en")
|
|
message.Body = "Hi"
|
|
message.Subject = "Msg Subject"
|
|
|
|
data, err := xml.Marshal(message)
|
|
if err != nil {
|
|
t.Errorf("cannot marshal xml structure")
|
|
}
|
|
|
|
parsedMessage := Message{}
|
|
if err = xml.Unmarshal(data, &parsedMessage); err != nil {
|
|
t.Errorf("Unmarshal(%s) returned error", data)
|
|
}
|
|
|
|
if !xmlEqual(parsedMessage, message) {
|
|
t.Errorf("non matching items\n%s", cmp.Diff(parsedMessage, message))
|
|
}
|
|
}
|