mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-09 15:32:54 +01:00
Fix in the storage of the original Middleware
This commit is contained in:
parent
6f93e5835e
commit
2bd6851c78
2 changed files with 16 additions and 3 deletions
2
msg.go
2
msg.go
|
@ -722,7 +722,7 @@ func (m *Msg) WriteTo(w io.Writer) (int64, error) {
|
|||
// the io.WriteTo interface but will skip the given Middleware
|
||||
func (m *Msg) WriteToSkipMiddleware(w io.Writer, mt MiddlewareType) (int64, error) {
|
||||
var omwl, mwl []Middleware
|
||||
copy(omwl, m.middlewares)
|
||||
omwl = m.middlewares
|
||||
for i := range m.middlewares {
|
||||
if m.middlewares[i].Type() == mt {
|
||||
continue
|
||||
|
|
17
msg_test.go
17
msg_test.go
|
@ -1600,15 +1600,28 @@ func TestMsg_WriteToSkipMiddleware(t *testing.T) {
|
|||
wbuf := bytes.Buffer{}
|
||||
n, err := m.WriteToSkipMiddleware(&wbuf, "uppercase")
|
||||
if err != nil {
|
||||
t.Errorf("WriteTo() failed: %s", err)
|
||||
t.Errorf("WriteToSkipMiddleware() failed: %s", err)
|
||||
return
|
||||
}
|
||||
if n != int64(wbuf.Len()) {
|
||||
t.Errorf("WriteTo() failed: expected written byte length: %d, got: %d", n, wbuf.Len())
|
||||
t.Errorf("WriteToSkipMiddleware() failed: expected written byte length: %d, got: %d", n, wbuf.Len())
|
||||
}
|
||||
if !strings.Contains(wbuf.String(), "Subject: This is @ test") {
|
||||
t.Errorf("WriteToSkipMiddleware failed. Unable to find encoded subject")
|
||||
}
|
||||
|
||||
wbuf2 := bytes.Buffer{}
|
||||
n, err = m.WriteTo(&wbuf2)
|
||||
if err != nil {
|
||||
t.Errorf("WriteTo() failed: %s", err)
|
||||
return
|
||||
}
|
||||
if n != int64(wbuf2.Len()) {
|
||||
t.Errorf("WriteTo() failed: expected written byte length: %d, got: %d", n, wbuf2.Len())
|
||||
}
|
||||
if !strings.Contains(wbuf2.String(), "Subject: THIS IS @ TEST") {
|
||||
t.Errorf("WriteToSkipMiddleware failed. Unable to find encoded and upperchase subject")
|
||||
}
|
||||
}
|
||||
|
||||
// TestMsg_Write tests the Write() method of the Msg
|
||||
|
|
Loading…
Reference in a new issue