mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2024-11-21 01:52:01 -08:00
Reset Tests
Will come with MaM (XEP-313) implementation
This commit is contained in:
parent
8798ff6fc1
commit
70ef1d575f
@ -1,79 +1,28 @@
|
|||||||
package stanza_test
|
package stanza_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
|
||||||
"gosrc.io/xmpp/stanza"
|
"gosrc.io/xmpp/stanza"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Limiting the number of items
|
// Limiting the number of items
|
||||||
func TestNewResultSetReq(t *testing.T) {
|
func TestNewResultSetReq(t *testing.T) {
|
||||||
expectedRq := "<iq type=\"set\" id=\"limit1\" to=\"users.jabber.org\"> <query xmlns=\"jabber:iq:search\"> " +
|
expectedRq := "<iq id=\"q29302\" type=\"set\"> <query xmlns=\"urn:xmpp:mam:2\"> " +
|
||||||
"<nick>Pete</nick> <set xmlns=\"http://jabber.org/protocol/rsm\"> <max>10</max> </set> </query> </iq>"
|
"<x type=\"submit\" xmlns=\"jabber:x:data\"> <field type=\"hidden\" var=\"FORM_TYPE\"> " +
|
||||||
|
"<value>urn:xmpp:mam:2</value> </field> <field var=\"start\"> <value>2010-08-07T00:00:00Z</value> </field> </x> " +
|
||||||
items := []stanza.Node{
|
"<set xmlns=\"http://jabber.org/protocol/rsm\"> <max>10</max> </set> </query> </iq>"
|
||||||
{
|
|
||||||
XMLName: xml.Name{Local: "nick"},
|
|
||||||
Content: "Pete",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
maxVal := 10
|
maxVal := 10
|
||||||
rs := &stanza.ResultSet{
|
rs := &stanza.ResultSet{
|
||||||
Max: &maxVal,
|
Max: &maxVal,
|
||||||
}
|
}
|
||||||
|
|
||||||
rq, err := stanza.NewResultSetReq("users.jabber.org", "jabber:iq:search", items, rs)
|
// TODO when Mam is implemented
|
||||||
if err != nil {
|
_ = expectedRq
|
||||||
t.Fatalf("failed to build the result set request : %v", err)
|
_ = rs
|
||||||
}
|
|
||||||
rq.Id = "limit1"
|
|
||||||
|
|
||||||
data, err := xml.Marshal(rq)
|
|
||||||
if err := compareMarshal(expectedRq, string(data)); err != nil {
|
|
||||||
t.Fatalf(err.Error())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnmarshalResultSeqReq(t *testing.T) {
|
func TestUnmarshalResultSeqReq(t *testing.T) {
|
||||||
//expectedRq := "<iq type=\"set\" id=\"limit1\" to=\"users.jabber.org\"> <query xmlns=\"jabber:iq:search\"> " +
|
// TODO when Mam is implemented
|
||||||
// "<nick>Pete</nick> <set xmlns=\"http://jabber.org/protocol/rsm\"> <max>10</max> </set> </query> </iq>"
|
|
||||||
//var uReq stanza.IQ
|
|
||||||
//err := xml.Unmarshal([]byte(expectedRq), &uReq)
|
|
||||||
//if err != nil {
|
|
||||||
// t.Fatalf(err.Error())
|
|
||||||
//}
|
|
||||||
//items := []stanza.Node{
|
|
||||||
// {
|
|
||||||
// XMLName: xml.Name{Local: "nick"},
|
|
||||||
// Content: "Pete",
|
|
||||||
// },
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//maxVal := 10
|
|
||||||
//rs := &stanza.ResultSet{
|
|
||||||
// XMLName: xml.Name{Local: "set", Space: "http://jabber.org/protocol/rsm"},
|
|
||||||
// Max: &maxVal,
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//rq, err := stanza.NewResultSetReq("users.jabber.org", "jabber:iq:search", items, rs)
|
|
||||||
//if err != nil {
|
|
||||||
// t.Fatalf("failed to build the result set request : %v", err)
|
|
||||||
//}
|
|
||||||
//rq.Id = "limit1"
|
|
||||||
//
|
|
||||||
//// Namespace is unmarshalled as of parent for nodes in the payload. To DeepEqual, we need to set the namespace in
|
|
||||||
//// the "expectedRq"
|
|
||||||
//n, ok := rq.Payload.(*stanza.QuerySet)
|
|
||||||
//if !ok {
|
|
||||||
// t.Fatalf("payload is not a query set: %v", ok)
|
|
||||||
//}
|
|
||||||
//n.Nodes[0].XMLName.Space = stanza.NSQuerySet
|
|
||||||
//
|
|
||||||
//data, err := xml.Marshal(rq)
|
|
||||||
//fmt.Println(string(data))
|
|
||||||
//if !reflect.DeepEqual(rq, uReq) {
|
|
||||||
// t.Fatalf("nope")
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user