Use an approach to build stanza that do not require a "builder" abstraction

This commit is contained in:
Mickael Remond
2019-06-27 14:30:23 +02:00
parent 1dacc663d3
commit 20a66dc47d
7 changed files with 159 additions and 100 deletions

View File

@@ -37,11 +37,11 @@ func TestUnmarshalIqs(t *testing.T) {
func TestGenerateIq(t *testing.T) {
iq := stanza.NewIQ(stanza.Attrs{Type: stanza.IQTypeResult, From: "admin@localhost", To: "test@localhost", Id: "1"})
payload := stanza.DiscoInfo{
Identity: stanza.Identity{
Name: "Test Gateway",
Category: "gateway",
Type: "mqtt",
},
Identity: []stanza.Identity{
{Name: "Test Gateway",
Category: "gateway",
Type: "mqtt",
}},
Features: []stanza.Feature{
{Var: stanza.NSDiscoInfo},
{Var: stanza.NSDiscoItems},
@@ -63,8 +63,8 @@ func TestGenerateIq(t *testing.T) {
t.Errorf("Unmarshal(%s) returned error", data)
}
if !xmlEqual(parsedIQ.Payload, iq.Payload) {
t.Errorf("non matching items\n%s", cmp.Diff(parsedIQ.Payload, iq.Payload))
if !xmlEqual(iq.Payload, parsedIQ.Payload) {
t.Errorf("non matching items\n%s", xmlDiff(iq.Payload, parsedIQ.Payload))
}
}