More tests

This commit is contained in:
Winni Neessen 2022-09-11 22:05:43 +02:00
parent 885d80aeb7
commit c52a437f7f
Signed by: wneessen
GPG key ID: 5F3AF39B820C119D

View file

@ -775,6 +775,27 @@ func TestClient_auth(t *testing.T) {
}
}
// TestValidateLine tests the validateLine() method
func TestValidateLine(t *testing.T) {
tests := []struct {
name string
value string
sf bool
}{
{"valid line", "valid line", false},
{`invalid line: \n`, "invalid line\n", true},
{`invalid line: \r`, "invalid line\r", true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := validateLine(tt.value); err != nil && !tt.sf {
t.Errorf("validateLine failed: %s", err)
}
})
}
}
// getTestConnection takes environment variables to establish a connection to a real
// SMTP server to test all functionality that requires a connection
func getTestConnection(auth bool) (*Client, error) {