Removed definedCondition in favor of Generic.
--- a/structs.go Wed Dec 28 13:24:08 2011 -0700
+++ b/structs.go Wed Dec 28 13:28:45 2011 -0700
@@ -43,18 +43,11 @@
// <stream:error>
// BUG(cjyar) Can this be consolidated with Error? Hide it if not.
type StreamError struct {
- Any definedCondition
+ Any Generic
Text *errText
}
var _ xml.Marshaler = &StreamError{}
-// BUG(cjyar) Replace this with Generic.
-type definedCondition struct {
- // Must always be in namespace nsStreams
- XMLName xml.Name
- Chardata string `xml:"chardata"`
-}
-
type errText struct {
Lang string `xml:"attr"`
Text string `xml:"chardata"`
--- a/structs_test.go Wed Dec 28 13:24:08 2011 -0700
+++ b/structs_test.go Wed Dec 28 13:28:45 2011 -0700
@@ -69,13 +69,13 @@
func TestStreamErrorMarshal(t *testing.T) {
name := xml.Name{Space: nsStreams, Local: "ack"}
- e := &StreamError{Any: definedCondition{XMLName: name}}
+ e := &StreamError{Any: Generic{XMLName: name}}
exp := `<stream:error><ack xmlns="` + nsStreams +
`"></ack></stream:error>`;
assertMarshal(t, exp, e)
txt := errText{Lang: "pt", Text: "things happen"}
- e = &StreamError{Any: definedCondition{XMLName: name}, Text: &txt}
+ e = &StreamError{Any: Generic{XMLName: name}, Text: &txt}
exp = `<stream:error><ack xmlns="` + nsStreams +
`"></ack><text xmlns="` + nsStreams +
`" xml:lang="pt">things happen</text></stream:error>`
--- a/xmpp_test.go Wed Dec 28 13:24:08 2011 -0700
+++ b/xmpp_test.go Wed Dec 28 13:28:45 2011 -0700
@@ -78,15 +78,15 @@
}
func TestWriteError(t *testing.T) {
- se := &StreamError{Any: definedCondition{XMLName:
- xml.Name{Local: "blah"}}}
+ se := &StreamError{Any: Generic{XMLName: xml.Name{Local:
+ "blah"}}}
str := testWrite(se)
exp := `<stream:error><blah></blah></stream:error>`
assertEquals(t, exp, str)
- se = &StreamError{Any: definedCondition{XMLName:
- xml.Name{Space: nsStreams, Local: "foo"}},
- Text: &errText{Lang: "ru", Text: "Пошёл ты"}}
+ se = &StreamError{Any: Generic{XMLName: xml.Name{Space:
+ nsStreams, Local: "foo"}}, Text:
+ &errText{Lang: "ru", Text: "Пошёл ты"}}
str = testWrite(se)
exp = `<stream:error><foo xmlns="` + nsStreams +
`"></foo><text xmlns="` + nsStreams +