From 19717723945d3d40374ba5929bfc7b1cc6b3539b Mon Sep 17 00:00:00 2001 From: Martin/Geno Date: Mon, 24 Jun 2019 16:38:22 +0200 Subject: [PATCH] fix everything --- pres_muc.go | 8 ++++---- pres_muc_test.go | 34 ++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/pres_muc.go b/pres_muc.go index 10d947e..b61f0ae 100644 --- a/pres_muc.go +++ b/pres_muc.go @@ -18,10 +18,10 @@ type MucPresence struct { // History implements XEP-0045: Multi-User Chat - 19.1 type History struct { - MaxChars int `xml:"maxchars,attr,omitempty"` - MaxStanzas int `xml:"maxstanzas,attr,omitempty"` - Seconds int `xml:"seconds,attr,omitempty"` - Since time.Time `xml:"since,attr,omitempty"` + MaxChars *int `xml:"maxchars,attr,omitempty"` + MaxStanzas *int `xml:"maxstanzas,attr,omitempty"` + Seconds *int `xml:"seconds,attr,omitempty"` + Since *time.Time `xml:"since,attr,omitempty"` } func init() { diff --git a/pres_muc_test.go b/pres_muc_test.go index 7200fc0..532bc0a 100644 --- a/pres_muc_test.go +++ b/pres_muc_test.go @@ -54,30 +54,32 @@ func TestMucHistory(t *testing.T) { t.Error("muc presence extension was not found") } - if muc.History.MaxStanzas != 20 { + if *muc.History.MaxStanzas != 20 { t.Errorf("incorrect max stanza: '%d'", muc.History.MaxStanzas) } } // https://xmpp.org/extensions/xep-0045.html#example-37 func TestMucNoHistory(t *testing.T) { - str := ` - - - -` + str := "" + + "" + + "" + + "" + + "" + + maxstanzas := 0 pres := xmpp.Presence{Attrs: xmpp.Attrs{ - From: "hag66@shakespeare.lit/pda", - Id: "n13mt3l", - To: "coven@chat.shakespeare.lit/thirdwitch", - }, + From: "hag66@shakespeare.lit/pda", + Id: "n13mt3l", + To: "coven@chat.shakespeare.lit/thirdwitch", + }, Extensions: []xmpp.PresExtension{ xmpp.MucPresence{ - History: xmpp.History{MaxStanzas: 0}, + History: xmpp.History{MaxStanzas: &maxstanzas}, }, }, } @@ -86,7 +88,7 @@ func TestMucNoHistory(t *testing.T) { t.Error("error on encode:", err) } - if data != str { - t.Errorf("incorrect max stanza: '%d'", muc.History.MaxStanzas) + if string(data) != str { + t.Errorf("incorrect stanza: \n%s\n%s", str, data) } }