From c52a437f7fefa26efdb2872b03b6d34b032b2f89 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sun, 11 Sep 2022 22:05:43 +0200 Subject: [PATCH] More tests --- client_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/client_test.go b/client_test.go index f47ef4f..8491ac5 100644 --- a/client_test.go +++ b/client_test.go @@ -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) {