mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-15 02:12:55 +01:00
Add debug logging to client creation in tests
Introduce `WithDebugLog()` in client creation for enhanced logging during tests. Correct handling of certain SMTP command errors by replacing `return` with `break` in switch cases for proper loop continuation.
This commit is contained in:
parent
74fa3f6f62
commit
ea57644a8e
1 changed files with 5 additions and 4 deletions
|
@ -1668,7 +1668,7 @@ func TestClient_DialWithContext(t *testing.T) {
|
||||||
ctxDial, cancelDial := context.WithTimeout(ctx, time.Millisecond*500)
|
ctxDial, cancelDial := context.WithTimeout(ctx, time.Millisecond*500)
|
||||||
t.Cleanup(cancelDial)
|
t.Cleanup(cancelDial)
|
||||||
|
|
||||||
client, err := NewClient(DefaultHost, WithPort(serverPort), WithTLSPolicy(NoTLS))
|
client, err := NewClient(DefaultHost, WithPort(serverPort), WithTLSPolicy(NoTLS), WithDebugLog())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create new client: %s", err)
|
t.Fatalf("failed to create new client: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -3725,14 +3725,14 @@ func handleTestServerConnection(connection net.Conn, props *serverProps) {
|
||||||
case strings.HasPrefix(data, "EHLO"), strings.HasPrefix(data, "HELO"):
|
case strings.HasPrefix(data, "EHLO"), strings.HasPrefix(data, "HELO"):
|
||||||
if len(strings.Split(data, " ")) != 2 {
|
if len(strings.Split(data, " ")) != 2 {
|
||||||
_ = writeLine("501 Syntax: EHLO hostname")
|
_ = writeLine("501 Syntax: EHLO hostname")
|
||||||
return
|
break
|
||||||
}
|
}
|
||||||
if props.FailOnHelo {
|
if props.FailOnHelo {
|
||||||
_ = writeLine("500 5.5.2 Error: fail on HELO")
|
_ = writeLine("500 5.5.2 Error: fail on HELO")
|
||||||
return
|
break
|
||||||
}
|
}
|
||||||
if err = writeLine("250-localhost.localdomain\r\n" + props.FeatureSet); err != nil {
|
if err = writeLine("250-localhost.localdomain\r\n" + props.FeatureSet); err != nil {
|
||||||
return
|
break
|
||||||
}
|
}
|
||||||
case strings.HasPrefix(data, "MAIL FROM:"):
|
case strings.HasPrefix(data, "MAIL FROM:"):
|
||||||
from := strings.TrimPrefix(data, "MAIL FROM:")
|
from := strings.TrimPrefix(data, "MAIL FROM:")
|
||||||
|
@ -3849,6 +3849,7 @@ func handleTestServerConnection(connection net.Conn, props *serverProps) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
_ = writeLine("221 2.0.0 Bye")
|
_ = writeLine("221 2.0.0 Bye")
|
||||||
|
return
|
||||||
default:
|
default:
|
||||||
_ = writeLine("500 5.5.2 Error: bad syntax")
|
_ = writeLine("500 5.5.2 Error: bad syntax")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue