79 } |
79 } |
80 |
80 |
81 func TestWriteError(t *testing.T) { |
81 func TestWriteError(t *testing.T) { |
82 se := &streamError{Any: Generic{XMLName: xml.Name{Local: "blah"}}} |
82 se := &streamError{Any: Generic{XMLName: xml.Name{Local: "blah"}}} |
83 str := testWrite(se) |
83 str := testWrite(se) |
84 exp := `<stream:error><blah></blah></stream:error>` |
84 exp := `<error xmlns="` + NsStream + `"><blah></blah></error>` |
85 assertEquals(t, exp, str) |
85 assertEquals(t, exp, str) |
86 |
86 |
87 se = &streamError{Any: Generic{XMLName: xml.Name{Space: NsStreams, Local: "foo"}}, Text: &errText{Lang: "ru", Text: "Пошёл ты"}} |
87 se = &streamError{Any: Generic{XMLName: xml.Name{Space: NsStreams, Local: "foo"}}, Text: &errText{Lang: "ru", Text: "Пошёл ты"}} |
88 str = testWrite(se) |
88 str = testWrite(se) |
89 exp = `<stream:error><foo xmlns="` + NsStreams + |
89 exp = `<error xmlns="` + NsStream + `"><foo xmlns="` + NsStreams + |
90 `"></foo><text xmlns="` + NsStreams + |
90 `"></foo><text xmlns="` + NsStreams + |
91 `" xml:lang="ru">Пошёл ты</text></stream:error>` |
91 `" xml:lang="ru">Пошёл ты</text></error>` |
92 assertEquals(t, exp, str) |
92 assertEquals(t, exp, str) |
93 } |
93 } |
94 |
94 |
95 func TestWriteStream(t *testing.T) { |
95 func TestWriteStream(t *testing.T) { |
96 ss := &stream{To: "foo.org", From: "bar.com", Id: "42", Lang: "en", Version: "1.0"} |
96 ss := &stream{To: "foo.org", From: "bar.com", Id: "42", Lang: "en", Version: "1.0"} |