Commit graph

1369 commits

Author SHA1 Message Date
602f8a6e29
Add comprehensive tests for message alternatives
Introduced tests for AddAlternativeString and AddAlternativeWriter methods, including variations for charset, encoding, content description, and simultaneous usages. Ensure accurate handling of content types, encodings, and body strings. This enhances coverage and reliability of message formatting features.
2024-10-27 15:10:01 +01:00
4db66696a6
Add tests for SetBodyTextTemplate method in msg_test.go
Implemented thorough unit tests to validate the SetBodyTextTemplate method in msg_test.go. These tests cover default behavior, handling of nil templates, and invalid templates, ensuring robustness and reliability.
2024-10-27 14:56:34 +01:00
f8caa5599b
Refactor buffer creation in msg.go
Replace `bytes.Buffer{}` with `bytes.NewBuffer(nil)` for buffer instantiation to improve clarity and consistency. This change simplifies the buffer creation process and aligns it with common Go practices.
2024-10-27 14:55:51 +01:00
35ffc95102
Add tests for SetBodyWriter and SetBodyHTMLTemplate
Introduced new tests to validate the functionality of `SetBodyWriter` with `WithPartEncoding` and `WithPartContentDescription`. Also added comprehensive tests for `SetBodyHTMLTemplate`, covering default behavior and error cases.
2024-10-27 14:50:14 +01:00
432e21f162
Refactor buffer initialization in message template execution
Change buffer initialization from an empty `bytes.Buffer` to `bytes.NewBuffer(nil)` to streamline buffer allocation. This adjustment ensures better flexibility and aligns with best practices in handling buffer slices.
2024-10-27 14:33:00 +01:00
0aa81d724b
Reorganize and cleanup msg_test.go
Removed redundant and commented-out test functions to improve code readability and maintainability. Moved the essential helper functions (checkAddrHeader and checkGenHeader) to the end to keep the structure organized.
2024-10-27 14:20:44 +01:00
78ee1a2a81
Fix timeout message in client_test.go
Updated the skip message to accurately reflect the timeout reason when closing the test server connection. This improves the clarity of the error reporting in tests.
2024-10-27 12:11:48 +01:00
b510d2654c
Handle timeout errors in test client cleanup
Added a check in the client cleanup function to skip the test if the client connection fails due to a timeout. This ensures that network-related timeouts do not cause test failures, providing more reliable test outcomes.
2024-10-27 12:10:51 +01:00
056ec60734
Remove newline characters in test data strings
Trim newline characters from test attachment and embed strings. Updated assertions to compare strings without trailing newlines for consistency.
2024-10-27 12:05:18 +01:00
cb5ac8b0e2
Suppress inspection for deprecated method usage in test
Added GoLand directive to suppress deprecation warnings for SetAttachements method in msg_test.go. This method is already fully tested by SetAttachments and the test is marked to be skipped.
2024-10-27 11:32:15 +01:00
6376f29190
Add ContentType tests and simplify error messages
Introduced new test cases for ContentType values to ensure proper handling. Additionally, simplified multiple error messages in existing tests to enhance readability and maintain consistency.
2024-10-27 11:27:38 +01:00
9a01629c47
Add unit tests for msg embed setters and unsetters
Introduce tests for `SetEmbeds` with single, multiple, and no files. Add `UnsetAllEmbeds` and `UnsetAllParts` tests to ensure embeds and attachments are removed correctly.
2024-10-27 10:49:02 +01:00
2dad9d36b2
Add embed and attachment tests
Introduced tests for embedding files and managing attachments in messages. Validated behavior for setting and unsetting attachments and retrieving embedded files with various scenarios.
2024-10-27 10:42:32 +01:00
c8c7d18ba9
Add test attachment with license information
Introduced a new test attachment file to the testdata directory. Included a corresponding license file to specify copyright and licensing details.
2024-10-27 10:30:20 +01:00
472a5a6454
Add tests for SetAttachments in msg_test.go
Implemented comprehensive tests for SetAttachments including scenarios with single, multiple, and no files. Additionally, deprecated the SetAttachements function and noted it as fully tested by SetAttachments.
2024-10-27 10:25:53 +01:00
f2619737e8
Add tests for Msg GetBoundary method
Introduce unit tests for the GetBoundary method in the Msg type. Ensure proper functionality for messages with and without a boundary set.
2024-10-27 10:13:14 +01:00
b7ca41af81
Remove redundant TestMsg_SetAttachments
Eliminated the TestMsg_SetAttachments function from the test suite as it duplicates functionality covered by other tests. Removing this redundant code improves maintainability and clarity.
2024-10-27 10:09:56 +01:00
66e25d82d3
Add test for GetAttachments method with no attachment
Introduced a new test case to check `GetAttachments` when no attachments are present in the message object. Removed the redundant `TestMsg_GetAttachments` function to simplify the test suite.
2024-10-27 10:09:25 +01:00
babf7b9780
Add tests for GetAttachments method in Msg
This commit introduces unit tests for the GetAttachments method in the Msg struct to ensure it correctly handles both single and multiple attachments. The tests verify the name and content of the attachments to validate the expected behavior.
2024-10-27 10:07:05 +01:00
43f9ffa3af
Add tests for GetGenHeader and GetParts methods in Msg
Introduce comprehensive tests for the GetGenHeader and GetParts methods. These tests cover single and multiple values for headers, body parts retrieval, and edge cases such as nil values, ensuring robustness and correctness.
2024-10-27 09:58:22 +01:00
e808e0b972
Add comprehensive unit tests for email address getters
Introduced unit tests for GetFrom, GetFromString, GetTo, GetToString, GetCc, GetCcString, GetBcc, and GetBccString methods. These tests cover scenarios with single, multiple, and no addresses, ensuring correct functionality of email address retrieval methods.
2024-10-26 23:20:23 +02:00
22f56a0143
Add tests for GetAddrHeaderString in msg_test.go
Add unit tests for the GetAddrHeaderString function to verify correct behavior for various header types and address counts. These tests ensure the function correctly handles single and multiple addresses, as well as scenarios with no addresses.
2024-10-26 22:57:47 +02:00
d16ae61f64
Add test for GetAddrHeader with multiple valid addresses
Introduce a new test to validate the behavior of GetAddrHeader for handling multiple addresses (to, cc, bcc). This test ensures that the function correctly processes and returns the expected addresses in various headers.
2024-10-26 22:53:30 +02:00
5e5bcef696
Add tests for Msg_GetAddrHeader
Introduce unit tests for the GetAddrHeader function in the Msg struct. These tests cover various scenarios, including valid addresses and handling of headers like "from," "to," "cc," and "bcc."
2024-10-26 22:50:31 +02:00
7b600534ea
Add tests for Msg.GetRecipients method
Implemented comprehensive tests for the Msg.GetRecipients method, covering various scenarios such as recipients in "to", "cc", "bcc" fields and combinations of these. Ensured correct handling of each case and validation against expected recipient counts and specific addresses.
2024-10-26 22:31:13 +02:00
842d4373f2
Add missing newline at EOF
Ensured the file ends with a newline to comply with best practices. This change improves code readability and consistency with other files in the repository.
2024-10-26 22:14:56 +02:00
5c2831c331
Add tests for MDN address formatting and GetSender logic
Implemented tests for `RequestMDNToFormat`, `RequestMDNAddTo`, and `RequestMDNAddToFormat` methods to ensure proper address handling. Added comprehensive `GetSender` method tests to verify sender retrieval in various scenarios. This enhances coverage and robustness of email message handling functionality.
2024-10-26 22:13:51 +02:00
4fe9022815
Refactor RequestMDNAddTo
Simplify the address handling for the "Disposition-Notification-To" header in msg.go. The code now directly reassigns the previously fetched addresses and ensures appending the new address effectively. This improves code readability and correctness in updating the header.
2024-10-26 22:13:37 +02:00
4f97cd8261
Initialize genHeader in RequestMDNTo method
Add checks to initialize `genHeader` if it is nil in the RequestMDNTo method to prevent potential nil map assignment errors. The newly implemented tests showed that this method was never actually working and the old test was inefficient to identify this.
2024-10-26 21:33:43 +02:00
9e51dba82a
Add new tests for Msg methods
Introduce tests for SetImportance, SetOrganization, SetUserAgent, and IsDelivered methods in the Msg type. These additions ensure the correct behavior and robustness of the email handling functionality.
2024-10-26 21:07:48 +02:00
cf117d320b
Add nil check in testMessage helper function
Added a conditional check to ensure 'NewMsg()' does not return nil in the 'testMessage' helper function. This update will prevent potential nil pointer dereferences and improve the robustness of the test.
2024-10-26 21:07:04 +02:00
42c63791ef
Move delivery status update after writer close check
Relocated the `isDelivered` flag update to occur after the writer's close method validation. This ensures that the message delivery status is only marked as true if no errors arise during the writer close process. This showed up in the new test cases that covered errors on closing the DATA channel. This can already happen before the first byte is sent to the server. Therefore isDelivered should be set after a successful close.
2024-10-26 21:06:21 +02:00
f5279cd584
Refactor character encoding test cases formatting
Reformatted the test cases for European umlaut characters for consistency and readability. This change does not affect the execution or output of the tests.
2024-10-26 20:22:04 +02:00
ef3f103c30
Add additional tests for setting message headers
Introduce tests for SetMessageIDWithValue, SetDate, and SetDateWithValue functions. Enhance coverage and validation for these methods by comparing generated headers and parsed dates.
2024-10-26 20:08:16 +02:00
ae15a12ce5
Refactor SetDate to use SetDateWithValue
Replaces direct time formatting in SetDate with a call to SetDateWithValue, improving code reusability and readability. The new approach centralizes date formatting logic in one method.
2024-10-26 19:57:02 +02:00
ea5b02bfdd
Add tests for SetMessageID and GetMessageID methods
Introduce unit tests to ensure SetMessageID generates unique IDs and GetMessageID correctly formats various input IDs. Additionally, verify GetMessageID returns an empty string when no ID is set.
2024-10-26 19:30:48 +02:00
591425bb99
Add test for European umlaut characters and remove others
Added a test case for European umlaut characters in msg_test.go. Removed redundant test cases related to address handlers (To, Cc, Bcc) and other helper methods to streamline the code.
2024-10-26 19:10:25 +02:00
007286fc5e
Add unit tests for Msg.Subject() method
Introduced unit tests to verify the encoding of different character sets in the Msg.Subject() method. Tests include cases for Latin characters, Japanese, Simplified Chinese, Cyrillic, and Emoji to ensure proper encoding handling.
2024-10-26 19:03:31 +02:00
5b602be818
Add tests for ReplyToFormat method
Implement new tests for the Msg.ReplyToFormat method to ensure it correctly handles both valid and invalid email addresses. These tests validate the ReplyTo header formatting and error handling.
2024-10-26 18:46:46 +02:00
96d45c26bc
Add tests for Msg.ReplyTo function
Introduce unit tests for the `ReplyTo` method in the `Msg` struct to validate both correct handling of valid email addresses and proper failure responses for invalid ones. Further, refactor and add helper functions to check generated headers in messages.
2024-10-26 18:40:53 +02:00
953a4b4df1
Add Bcc-related unit tests to msg_test.go
Introduce comprehensive unit tests for Bcc functionalities, including validation of single and multiple addresses, various invalid input scenarios, and RFC5322 compliance checks. Additionally, implement tests for AddBcc, AddBccFormat, BccIgnoreInvalid, and BccFromString methods to ensure robust handling of different Bcc cases.
2024-10-26 18:29:51 +02:00
f079ea09eb
Improve BccFromString to handle spaces and empty addresses
Trim spaces from email addresses and skip empty addresses in BccFromString method. This ensures that the BCC list only includes valid, non-empty email addresses, enhancing email sending reliability.
2024-10-26 18:29:26 +02:00
03cb09c3bd
Add tests for Cc, AddCc, AddCcFormat, CcIgnoreInvalid, and CcFromString
This commit introduces comprehensive tests for various "Cc" related methods in the `Msg` struct. It includes test cases for valid and invalid email addresses for methods: `Cc`, `AddCc`, `AddCcFormat`, `CcIgnoreInvalid`, and `CcFromString`, ensuring robust handling of different scenarios and edge cases.
2024-10-26 18:22:01 +02:00
855d7f0867
Refine CcFromString to handle spaces and empty addresses.
This change ensures that email addresses with leading or trailing spaces are trimmed, and empty addresses resulting from multiple commas are ignored. This helps prevent potential errors with malformed email addresses in the "Cc" field.
2024-10-26 18:21:50 +02:00
d7b32480fd
Handle test server connection timeouts
Add logic to skip tests if there's a timeout error while connecting to the test server. This ensures that transient network issues do not cause test failures.
2024-10-26 17:33:52 +02:00
23399ed84c
Change DefaultHost to loopback address
Updated DefaultHost from "localhost" to "127.0.0.1" in client_test.go. This change ensures consistent and direct communication with the local machine, avoiding potential issues with DNS resolution of "localhost".
2024-10-26 17:17:58 +02:00
90e3162a22
Update CI to support older Go versions
Added Go 1.19 and 1.20 to the CI matrix to extend compatibility testing. This ensures that our project continues to work with these older versions of Go.
2024-10-26 17:11:21 +02:00
273a26ca53
Add tests for Go 1.21+ compatibility
Moved some tests that use JSONlog (which requires Go 1.21+) to a separate file that is skipped on older Go versions.
2024-10-26 17:10:50 +02:00
a815c58571
Update CI workflow to install nullmailer instead of ssmtp
Replacing ssmtp with nullmailer ensures better compatibility with the updated email delivery requirements. The DEBIAN_FRONTEND=noninteractive parameter was also added to avoid interactive prompts during installation.
2024-10-26 16:45:07 +02:00
c33900ca29
Add sudo to apt-get commands in CI workflow
Previously, the apt-get commands lacked the necessary sudo prefix, which could lead to permission issues during the CI process. This change ensures that updates, upgrades, and installations are executed with the appropriate permissions.
2024-10-26 16:26:49 +02:00