func TestNewUnSubRequest(t *testing.T) {
	expectedReq := "<iq type=\"set\"id=\"unsub1\"to=\"pubsub.shakespeare.lit\"> " +
		"<pubsub xmlns=\"http://jabber.org/protocol/pubsub\"> " +
		"<unsubscribe node=\"princely_musings\"jid=\"francisco@denmark.lit\"></unsubscribe> </pubsub> </iq>"
	subInfo := stanza.SubInfo{
		Node: "princely_musings", Jid: "francisco@denmark.lit",
	}
	subR, err := stanza.NewUnsubRq("pubsub.shakespeare.lit", subInfo)
	if err != nil {
		t.Fatalf("failed to create an unsub request: %v", err)
	}
	subR.Id = "unsub1"
	if _, e := checkMarshalling(t, subR); e != nil {
		t.Fatalf("Failed to check marshalling for generated sub request : %s", e)
	}
	pubsub, ok := subR.Payload.(*stanza.PubSubGeneric)
	if !ok {
		t.Fatalf("payload is not a pubsub !")
	}
	if pubsub.Unsubscribe == nil {
		t.Fatalf("Unsubscribe tag should be present in sub config options request")
	}
	data, err := xml.Marshal(subR)
	if err := compareMarshal(expectedReq, string(data)); err != nil {
		t.Fatalf(err.Error())
	}
}
***********************************
* 6.2 Unsubscribe from a Node
***********************************
package stanza_test
import (
	"encoding/xml"
	"errors"
	"gosrc.io/xmpp/stanza"
	"strings"
	"testing"
)
var submitFormExample = stanza.NewForm([]*stanza.Field{
	{Var: "FORM_TYPE", Type: stanza.FieldTypeHidden, ValuesList: []string{"http://jabber.org/protocol/pubsub#node_config"}},
	{Var: "pubsub#title", ValuesList: []string{"Princely Musings (Atom)"}},
	{Var: "pubsub#deliver_notifications", ValuesList: []string{"1"}},
	{Var: "pubsub#access_model", ValuesList: []string{"roster"}},
	{Var: "pubsub#roster_groups_allowed", ValuesList: []string{"friends", "servants", "courtiers"}},
	{Var: "pubsub#type", ValuesList: []string{"http://www.w3.org/2005/Atom"}},
	{
		Var:        "pubsub#notification_type",
		Type:       "list-single",
		Label:      "Specify the delivery style for event notifications",
		ValuesList: []string{"headline"},
		Options: []stanza.Option{
			{ValuesList: []string{"normal"}},
			{ValuesList: []string{"headline"}},
		},
	},
}, stanza.FormTypeSubmit)
func TestNewSubRequest(t *testing.T) {
	expectedReq := "<iq type=\"set\"id=\"sub1\"to=\"pubsub.shakespeare.lit\"> " +
		"<pubsub xmlns=\"http://jabber.org/protocol/pubsub\"> <subscribe node=\"princely_musings\"jid=\"francisco@denmark.lit\"></subscribe>" +
		" </pubsub> </iq>"
	subInfo := stanza.SubInfo{
		Node: "princely_musings", Jid: "francisco@denmark.lit",
	}
	subR, err := stanza.NewSubRq("pubsub.shakespeare.lit", subInfo)
	if err != nil {
		t.Fatalf("failed to create a sub request: %v", err)
	}
	subR.Id = "sub1"
	if _, e := checkMarshalling(t, subR); e != nil {
		t.Fatalf("Failed to check marshalling for generated sub request : %s", e)
	}
	data, err := xml.Marshal(subR)
	if err := compareMarshal(expectedReq, string(data)); err != nil {
		t.Fatalf(err.Error())
	}
}
func TestNewSubResp(t *testing.T) {
	response := `
<iq type="result" from="pubsub.shakespeare.lit" to="francisco@denmark.lit/barracks" id="sub1">
    <pubsub xmlns="http://jabber.org/protocol/pubsub">
        <subscription node="princely_musings" jid="francisco@denmark.lit"
            subid="ba49252aaa4f5d320c24d3766f0bdcade78c78d3" subscription="subscribed"/>
    </pubsub>
</iq>
`
	pubsub, err := getPubSubGenericPayload(response)
	if err != nil {
		t.Fatalf(err.Error())
	}
	if pubsub.Subscription == nil {
		t.Fatalf("subscription node is nil")
	}
	if pubsub.Subscription.Node == "" ||
		pubsub.Subscription.Jid == "" ||
		pubsub.Subscription.SubId == nil ||
		pubsub.Subscription.SubStatus == "" {
		t.Fatalf("one or more of the subscription attributes was not successfully decoded")
	}
}