Rename dsnmrtype to dsnReturnType in client.go

Refactor variable names for consistency. The `dsnmrtype` variable has been renamed to `dsnReturnType` across the client and test files to improve code readability and maintain uniformity.
This commit is contained in:
Winni Neessen 2024-10-04 20:30:43 +02:00
parent ef3da39840
commit f7c12d412b
Signed by: wneessen
GPG key ID: 385AC9889632126E
2 changed files with 11 additions and 11 deletions

View file

@ -106,8 +106,8 @@ type (
// dialContextFunc is the DialContextFunc that is used by the Client to connect to the SMTP server. // dialContextFunc is the DialContextFunc that is used by the Client to connect to the SMTP server.
dialContextFunc DialContextFunc dialContextFunc DialContextFunc
// dsnmrtype defines the DSNMailReturnOption in case DSN is enabled // dsnReturnType defines the DSNMailReturnOption in case DSN is enabled
dsnmrtype DSNMailReturnOption dsnReturnType DSNMailReturnOption
// dsnrntype defines the DSNRcptNotifyOption in case DSN is enabled // dsnrntype defines the DSNRcptNotifyOption in case DSN is enabled
dsnrntype []string dsnrntype []string
@ -398,7 +398,7 @@ func WithPassword(password string) Option {
func WithDSN() Option { func WithDSN() Option {
return func(c *Client) error { return func(c *Client) error {
c.requestDSN = true c.requestDSN = true
c.dsnmrtype = DSNMailReturnFull c.dsnReturnType = DSNMailReturnFull
c.dsnrntype = []string{string(DSNRcptNotifyFailure), string(DSNRcptNotifySuccess)} c.dsnrntype = []string{string(DSNRcptNotifyFailure), string(DSNRcptNotifySuccess)}
return nil return nil
} }
@ -418,7 +418,7 @@ func WithDSNMailReturnType(option DSNMailReturnOption) Option {
} }
c.requestDSN = true c.requestDSN = true
c.dsnmrtype = option c.dsnReturnType = option
return nil return nil
} }
} }
@ -874,8 +874,8 @@ func (c *Client) sendSingleMsg(message *Msg) error {
} }
if c.requestDSN { if c.requestDSN {
if c.dsnmrtype != "" { if c.dsnReturnType != "" {
c.smtpClient.SetDSNMailReturnOption(string(c.dsnmrtype)) c.smtpClient.SetDSNMailReturnOption(string(c.dsnReturnType))
} }
} }
if err = c.smtpClient.Mail(from); err != nil { if err = c.smtpClient.Mail(from); err != nil {

View file

@ -486,9 +486,9 @@ func TestWithDSN(t *testing.T) {
if !c.requestDSN { if !c.requestDSN {
t.Errorf("WithDSN failed. c.requestDSN expected to be: %t, got: %t", true, c.requestDSN) t.Errorf("WithDSN failed. c.requestDSN expected to be: %t, got: %t", true, c.requestDSN)
} }
if c.dsnmrtype != DSNMailReturnFull { if c.dsnReturnType != DSNMailReturnFull {
t.Errorf("WithDSN failed. c.dsnmrtype expected to be: %s, got: %s", DSNMailReturnFull, t.Errorf("WithDSN failed. c.dsnReturnType expected to be: %s, got: %s", DSNMailReturnFull,
c.dsnmrtype) c.dsnReturnType)
} }
if c.dsnrntype[0] != string(DSNRcptNotifyFailure) { if c.dsnrntype[0] != string(DSNRcptNotifyFailure) {
t.Errorf("WithDSN failed. c.dsnrntype[0] expected to be: %s, got: %s", DSNRcptNotifyFailure, t.Errorf("WithDSN failed. c.dsnrntype[0] expected to be: %s, got: %s", DSNRcptNotifyFailure,
@ -519,8 +519,8 @@ func TestWithDSNMailReturnType(t *testing.T) {
t.Errorf("failed to create new client: %s", err) t.Errorf("failed to create new client: %s", err)
return return
} }
if string(c.dsnmrtype) != tt.want { if string(c.dsnReturnType) != tt.want {
t.Errorf("WithDSNMailReturnType failed. Expected %s, got: %s", tt.want, string(c.dsnmrtype)) t.Errorf("WithDSNMailReturnType failed. Expected %s, got: %s", tt.want, string(c.dsnReturnType))
} }
}) })
} }