Commit graph

94 commits

Author SHA1 Message Date
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
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
960c015a93
Remove IPv6 and IPv4 test cases from msg_test.go
Removed test cases for IPv6 and IPv4 addresses from `msg_test.go` as they are no longer required. Also made a minor formatting adjustment to the `checkAddrHeader` function signature for better readability.
2024-10-26 15:45:01 +02:00
3a3eaed348
Refactor address header tests to use checkAddrHeader
Consolidate repeated header validation logic into the `checkAddrHeader` helper function. This refactoring improves code readability and maintainability by reducing redundancy and potential for errors.
2024-10-26 02:07:44 +02:00
e08d36d0b8
Refactor address header validation in tests
Replace repeated address header validation code with a helper function `checkAddrHeader` to reduce redundancy and improve readability. Also, add new test cases for `ToFromString` to handle valid addresses with and without empty fields.
2024-10-25 20:21:17 +02:00
03da20fc39
Add unit tests for Msg_ToIgnoreInvalid behavior
Introduces new test cases to verify the Msg_ToIgnoreInvalid function handles various scenarios correctly. These tests check for behavior with valid addresses, invalid addresses, and a mix of both.
2024-10-25 19:43:05 +02:00
8b6a7927ef
Add dummy test function in msg_test.go
Introduce a new, empty test function `TestMsg_ToIgnoreInvalid` in `msg_test.go` to accommodate future test cases. This commit also aligns a comment for better readability.
2024-10-25 17:43:59 +02:00
1ea7b173c6
Add tests for Msg.AddToFormat
Introduced new test cases to validate Msg.AddToFormat functionality with both valid and invalid email addresses. Ensured proper error handling and address formatting in the message headers.
2024-10-25 17:16:46 +02:00
a7f81baa4b
Fix address references in tests and add AddTo functionality
Corrected incorrect address references in the `msg_test.go` file. Added new tests to validate the AddTo functionality, ensuring multiple addresses can be added and validated properly.
2024-10-25 17:13:22 +02:00
cb85a136c3
Add Goland noinspection comments to suppress deprecation warnings
This change adds `//goland:noinspection GoDeprecation` comments in the `msg_test.go` file. These comments suppress deprecation warnings for the `SetHeader` and `SetHeaderPreformatted` methods during test execution.
2024-10-25 17:05:22 +02:00
aa46b408ad
Add additional tests for From and To address handling
Refactor "From" related tests to improve error messages and add tests for the new "FromFormat" function. Introduce new tests to validate the "To" address handling, covering various valid and invalid address scenarios.
2024-10-25 17:03:57 +02:00
5d85be068d
Add comprehensive tests for email "From" field validation
Implemented extensive test cases for the "From" field in email messages, covering various valid and invalid email formats according to RFC5322. Verified correct handling for each scenario to ensure robustness of email address validation.
2024-10-25 16:36:34 +02:00
1caa2cfb92
Add tests for EnvelopeFrom and EnvelopeFromFormat methods
Implemented comprehensive tests for the EnvelopeFrom and EnvelopeFromFormat methods to ensure proper handling of valid and invalid email addresses. This includes validation of both address and format for the "EnvelopeFrom" header.
2024-10-25 15:14:06 +02:00
c8dbc9a735
Update tests for SetAddrHeader and add new test cases
Renamed existing test cases for clarity and added new test cases for SetAddrHeaderIgnoreInvalid function. The new tests cover multiple scenarios including valid/invalid addresses, and edge cases such as nil addrHeader map.
2024-10-25 15:00:53 +02:00
7d352bc58e
Add comprehensive tests for header and address methods
Implemented extensive unit tests for setting various headers and address fields in the `Msg` struct, including setting general headers, preformatted headers, and address headers with various scenarios to ensure correctness and robustness.
2024-10-25 12:18:26 +02:00
a2e9dbae11
Add unit tests for charset and header setting in messages
This commit introduces two new unit tests: `TestMsg_Charset` and `TestMsg_SetHeader`. These tests cover the functionality of setting and retrieving the character set and headers for messages, ensuring correctness and robustness.
2024-10-25 11:36:26 +02:00
1dba76948f
Simplify test descriptions in msg_test.go
Shortened the test case descriptions for better clarity and readability. Added a new test function 'TestMsg_Encoding' to verify encoding outputs.
2024-10-25 11:24:35 +02:00
120c2efd08
Refactor test cases with shared test data
Consolidated repetitive test data into shared variables to improve code maintainability and readability. This modification also helps in reducing redundancy and streamlining future updates to test data.
2024-10-25 11:18:09 +02:00
c4946af3ab
Refactor msg_test.go to streamline tests and reduce redundancy
Reorganized and condensed test cases for the NewMsg method by merging individual tests and removing obsolete functions. This improves maintainability and reduces duplication in the test suite.
2024-10-25 11:08:11 +02:00
5874911c91
Simplify Message-ID generation
Updated the SetMessageID method to generate a "Message-ID" using a
single randomly generated string combined with the hostname, replacing
the prior complex format that included process ID and multiple random
numbers. This change simplifies the code of the generated IDs.
2024-10-07 15:04:04 +02:00
f5d4cdafea
Increase test iterations for SetMessageID randomness check
Updated the TestMsg_SetMessageIDRandomness test to run 50,000 iterations instead of 100, ensuring a more robust evaluation of the Msg.SetMessageID method's randomness. Additionally, streamlined the retrieval of Message ID using GetMessageID.
2024-09-20 20:39:30 +02:00
69e211682c
Add GetMessageID method to Msg
Introduced GetMessageID to retrieve the Message ID from the Msg
2024-09-19 11:46:53 +02:00
Alexander Setzer
7caf0b8e19 Fix typo / inconsistency for (*Msg).SetAttachments 2024-08-14 14:55:08 +02:00
b88b67e2c7
Add GetBoundary method and corresponding test
The GetBoundary method has been added to the Msg struct in msg.go. Alongside this, a corresponding test method, TestMsg_GetBoundary, was introduced in msg_test.go to ensure the proper working of GetBoundary. This new method returns the boundary string of the Msg, which was previously inaccessible.
2024-07-02 10:58:13 +02:00
2e548512c6
Merge branch 'refs/heads/main' into feature/145_add-eml-parser-to-generate-msg-from-eml-files 2024-05-16 15:17:47 +02:00
dae7d80759
Add fuzzing tests for subject and from fields in msg_test.go
Included two new fuzzing tests for 'Subject' and 'From' to increase code coverage and reliability. These tests expand our checking strategy by using dynamic inputs and making sure no unexpected errors occur when dealing with a variety of possible input scenarios.
2024-03-23 16:46:21 +01:00
19a3cf61ed
Refactor variable names for code readability
Updated variable names in multiple files to enhance code readability and maintainability by replacing abbreviations with full descriptive names. This ensures adherence to the best practices of naming conventions in Go.
2024-02-27 11:21:28 +01:00
21d7b367bd
Update user agent test in msg_test.go
Updated the test "check default user agent" in `msg_test.go` to reflect dynamic versioning. The wantUserAgent field now uses fmt.Sprintf to combine the go-mail version dynamically, improving the accuracy of testing.
2024-02-26 21:05:52 +01:00
180f6f3a63
Add a new test for no default user agent in msg_test.go
A new test function named "TestNewMsgWithNoDefaultUserAgent" has been added in `msg_test.go` file. This function is meant to test 'NewMsg' function with 'WithNoDefaultUserAgent' parameter. The addition is devised to enhance the test coverage and ensure the noDefaultUserAgent field is functioning correctly.
2024-02-26 21:03:20 +01:00
grigorii
299490f8fa Add an option to skip adding a User-Agent (tests) 2024-02-26 10:30:33 -08:00
f759b1b5fb
Merge branch 'main' into feature/145_add-eml-parser-to-generate-msg-from-eml-files 2024-02-08 17:04:06 +01:00
a864be059c
Add "X-Auto-Response-Suppress" header and update SetBulk method
A new "X-Auto-Response-Suppress" header has been added. The SetBulk method has been updated to include this new header, as it is recommended for automated emails. This functionality is tested in the msg_test.go file.
2024-02-08 16:45:06 +01:00
8b19e497a0
Merge branch 'main' into feature/145_add-eml-parser-to-generate-msg-from-eml-files 2024-01-10 11:07:54 +01:00
rami
f445a55f7b Fixed msg_test.go 2023-12-25 12:17:55 +01:00
a12d9c327f
Merge branch 'main' into feature/145_add-eml-parser-to-generate-msg-from-eml-files 2023-12-07 13:21:30 +01:00
6268077b99
Make golangci-lint happy
Omitting nil redundant nil checks, as len() for []string is defined as zero
2023-11-30 09:14:31 +01:00
5dcbe712ae
Add null check to prevent empty file handle error in msg_test.go
Implemented a null check to ensure the 'fi' file handle is not empty. With the absence of this check, the test was continuing even when 'fi' was empty, leading to null pointer exceptions further down in the code.
2023-11-29 17:47:30 +01:00
ddcad3710d
Fix potential null pointer exceptions in msg_test.go
Added robustness and improved error handling in msg_test.go by adding null checks before calling values from the genHeader map in RequestMDNTo and related functions. This enhancement was necessary to avoid the operations on non-existing keys and potential null pointer exceptions.
2023-11-29 17:46:30 +01:00
fb17547e69
Improve error handling in msg.go
Added additional checks when calling values from the genHeader map in msg.go file. This is to prevent trying to operate on non-existing keys, hence avoiding possible null pointer exceptions. The checks ensure the key HeaderMessageID exists in the genHeader map before attempting to operate on it. This is essential for functions like RequestMDNTo, RequestMDNToFormat, and RequestMDNAddToFormat, thereby improving the robustness of the code.
2023-11-29 17:40:31 +01:00
5a4f814061
Protect against key not found in genHeader map in msg.go
Added checks to ensure the key HeaderMessageID exists in the genHeader map before attempting to operate on it in msg.go. This will prevent possible null pointer exceptions when trying to assign the key a value or append it to the mids slice.
2023-11-29 17:34:15 +01:00
fd313e23b6
Add checks for nil or empty Subject headers
Added condition checks in `msg_test.go` for nil or empty Subject headers in the assigned functions. If the Subject is found to be nil or its length is less than 1, an empty string is now appended to prevent issues arising from null pointers or non-existent Subject headers in email messages.
2023-11-29 17:26:47 +01:00
1e447b5f2c
Merge branch 'main' into feature/145_add-eml-parser-to-generate-msg-from-eml-files 2023-11-10 18:23:52 +01:00
43c26a37e3
Updated mail.Address initialization in tests to make golangci-lint happy
Tests for new mail address handling methods have been updated to use {Name:"", Address: "email@example.com"} format for initializing the []*mail.Address slices, instead of the previous shorthand {"", "email@example.com"}. This was done to increase code clarity and explicitness.
2023-11-10 18:14:44 +01:00
cc14864129
#152: Add new methods and tests for handling email addresses
Added new methods `ToFromString()`, `CcFromString()` and `BccFromString()` in msg.go file to handle strings of comma-separated email addresses.
2023-11-10 18:07:56 +01:00
6bda5d1aaa
Merge branch 'main' into feature/145_add-eml-parser-to-generate-msg-from-eml-files 2023-10-20 14:23:24 +02:00
leahoop
3c2c106cb4 #147 add remove attachments and embeds methods 2023-10-20 10:21:03 +08:00
e7c717d0fc
"Rename Mime10 to MIME10 in codebase
Renamed field 'Mime10' to 'MIME10' across multiple files for canonical representation and consistency with standard MIME naming format in the protocol."
2023-10-13 15:23:28 +02:00
438cfd60eb
Preparation for the v0.4.0 release:
- Bump version in doc.go
- Add sonarlint to .gitignore
- Update README to reflect the changes and contributors
- Fixed typos in auth_cram_md5_118.go, msg.go, msg_test.go, reader.go and smtp_ehlo_117.go
2023-05-31 09:34:45 +02:00