Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion framework/exterrors/smtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ func SMTPCode(err error, temporaryCode, permanentCode int) int {
func SMTPEnchCode(err error, code EnhancedCode) EnhancedCode {
if IsTemporary(err) {
code[0] = 4
} else {
code[0] = 5
}
code[0] = 5
return code
}
39 changes: 39 additions & 0 deletions framework/exterrors/smtp_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Maddy Mail Server - Composable all-in-one email server.
Copyright © 2019-2020 Max Mazurov <fox.cpp@disroot.org>, Maddy Mail Server contributors

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package exterrors

import (
"errors"
"testing"
)

func TestSMTPEnchCode(t *testing.T) {
temp := WithTemporary(errors.New("temp"), true)
perm := WithTemporary(errors.New("perm"), false)

if got := SMTPEnchCode(temp, EnhancedCode{0, 4, 0}); got != (EnhancedCode{4, 4, 0}) {
t.Errorf("temporary error: got %v, want 4.4.0", got)
}
if got := SMTPEnchCode(perm, EnhancedCode{0, 4, 0}); got != (EnhancedCode{5, 4, 0}) {
t.Errorf("permanent error: got %v, want 5.4.0", got)
}
if got := SMTPEnchCode(errors.New("plain"), EnhancedCode{0, 4, 0}); got != (EnhancedCode{5, 4, 0}) {
t.Errorf("plain error: got %v, want 5.4.0", got)
}
}
Loading