Commit graph

1357 commits

Author SHA1 Message Date
1c6b9faf15
Add tests for Msg.HasSendError method.
Introduce several unit tests for the Msg.HasSendError function to ensure its correct behavior under different conditions like unsent messages, failed deliveries, and temporary errors. This enhances the validation of message error states within the system.
2024-10-28 17:34:35 +01:00
7d670a1f24
Add temporary failure condition in client test
Introduce a new `FailTemp` property to simulate a temporary failure during the DATA transmission phase in tests. This helps ensure better coverage and handling of specific error conditions.
2024-10-28 17:31:11 +01:00
2f3809f33e
Add tests for Msg.UpdateReader method
Implemented new tests to validate the Msg.UpdateReader method, ensuring its functionality for both success and failure scenarios. Removed obsolete tests for Msg.NewReader to maintain code clarity and relevance.
2024-10-28 17:20:40 +01:00
4ecc6f2b0c
Refactor Msg tests and remove unused code
Reorganized message writing tests to create more concise and specific scenarios, including new context tests and WriteToFile tests. Removed outdated and redundant test cases to streamline the test suite.
2024-10-28 17:14:06 +01:00
a59173fae0
Refactor buffer initialization in NewReader.
Replaced bytes.Buffer{} with bytes.NewBuffer(nil) for buffer initialization in NewReader method of Msg. This change enhances clarity and consistency in buffer handling.
2024-10-28 17:04:44 +01:00
d39953c837
Update environment variables in CI workflow
Standardize variables by using expressions for consistency. This change ensures that all environment variables for Unix and Sendmail tests are sourced from GitHub variables.
2024-10-28 16:32:24 +01:00
6cbb6745bb
Add new test cases for message attachments and long headers
Introduce tests for "AttachFile" with a normal file and "WriteTo" with long headers. Additionally, remove outdated and redundant test functions.
2024-10-28 15:58:14 +01:00
4506472319
Add missing newline after test function
A newline was added after an anonymous function block to improve code readability. This change adheres to proper formatting practices and enhances the maintainability of the code.
2024-10-28 15:43:32 +01:00
759452f346
Refactor tests to remove redundant unix-specific cases
Unified the test cases for AttachFile, AttachReader, AttachReadSeeker, EmbedFile, EmbedReader, and EmbedReadSeeker by incorporating the previously separate UNIX-specific tests into the general test files. This change enhances maintainability by reducing code duplication and ensuring more consistent test coverage across platforms.
2024-10-28 15:42:20 +01:00
4eb9d8a1fa
Add tests for Msg.Write and WriteTo error handling
Implemented tests for the Msg.Write method and enhanced WriteTo error handling. Also added a failReadWriteSeekCloser type to explicitly simulate IO failures in tests, ensuring comprehensive reliability of error handling mechanisms.
2024-10-28 15:14:43 +01:00
afa65585a0
Add test for WriteToSkipMiddleware function in Msg structure
Implement a new test for the WriteToSkipMiddleware function to validate its behavior with normal mail parts. Ensure that the function properly skips the specified middleware and writes the message to a buffer correctly.
2024-10-28 14:58:55 +01:00
4a519a3b1f
Add tests for middleware application on messages
Introduced comprehensive test cases for applying middlewares (uppercase and encode) to messages. Also added tests for writing messages to memory buffers and parsing them back. Corrected messages in helper functions for consistency.
2024-10-28 14:54:42 +01:00
ae44d37d03
Add test for Msg_Reset function
This test ensures that the Reset method correctly clears all fields in the Msg struct. It verifies that the From, To, Subject, Body, Attachments, and Embeds fields are empty after calling Reset.
2024-10-28 12:30:13 +01:00
80bf7240b4
Remove redundant attachment and embed tests
Eliminated multiple test functions for file attachments and embeds, including TestMsg_AttachFile, TestMsg_AttachFromEmbedFS, and TestMsg_EmbedFile. These tests either duplicated functionality or were no longer relevant to the current code base. Simplifying the test suite enhances maintainability and reduces unnecessary checks.
2024-10-28 12:21:58 +01:00
f48ff6e150
Add tests for embedding functionalities in Msg
Introduce unit tests for EmbedReadSeeker, EmbedHTMLTemplate, EmbedTextTemplate, and EmbedFromEmbedFS methods in the Msg package. These tests cover various use cases and error scenarios, ensuring the correct handling of embedded content.
2024-10-28 12:17:20 +01:00
c395c83a06
Add tests for embedding files and readers
Introduced unit tests to verify the embedding of files and readers in messages, including tests specific to Unix file handling scenarios. These tests ensure correct handling of embed errors and proper cleanup of temporary files.
2024-10-28 12:01:31 +01:00
ae7b6a68c5
Add tests for the EmbedFile functionality in msg_test.go
This commit introduces three new test cases to validate the EmbedFile function in the msg_test.go file. The tests cover embedding an existing file, handling a non-existent file, and referencing pre-tested options.
2024-10-28 11:37:04 +01:00
d02f469658
Add test cases for AttachFromEmbedFS errors
Introduce two new test cases for the AttachFromEmbedFS method. These tests verify that the method correctly handles an invalid file path and a nil embed FS, ensuring error scenarios are properly managed.
2024-10-28 11:35:05 +01:00
e779777c9b
Add tests for message attachment methods using templates
Included unit tests to verify the functionality of the AttachHTMLTemplate and AttachTextTemplate methods, ensuring valid, invalid, and nil templates are handled correctly. Also added tests for AttachFromEmbedFS to validate attachments from embedded files.
2024-10-28 11:30:34 +01:00
f576b92ce2
Increase code coverage targets to 90% and tighten thresholds.
Updated project and patch coverage targets to 90% from 85% and 80%, respectively. Tightened thresholds from 5% to 2% to enforce stricter quality controls.
2024-10-28 11:30:01 +01:00
466c2892bf
Add AttachReadSeeker tests for Unix and general cases
Introduce tests for the AttachReadSeeker method, detailing scenarios for general use and Unix-specific paths. Ensure file handling and error conditions are properly validated to maintain robustness.
2024-10-28 09:34:05 +01:00
e7e0fe03bb
Remove redundant OS version from CI matrix
This commit eliminates the duplication of the '14.1' OS version in the CI workflow matrix configuration. Simplifying the matrix helps in avoiding redundant test runs and ensures a clearer CI process.
2024-10-27 21:00:22 +01:00
c0c4049964
Enable Unix write tests and fix OS version matrix.
Added a test environment variable to control Unix write tests and included their setup in the test function. Also corrected the OS version matrix by uncommenting '14.0' and '13.4'.
2024-10-27 20:59:24 +01:00
6a43cf4aaf
Rename and update tests for UNIX-specific functionality
Renamed `msg_nowin_test.go` to `msg_unix_test.go` to better reflect its purpose. Updated the file attachment test to use `/dev/mem` for Unix environments instead of a temporary file with restricted permissions, ensuring compatibility with continuous integration environments.
2024-10-27 20:46:16 +01:00
e74adb8b90
Update CI configuration for FreeBSD
Commented out older OS versions and added no copyback option. Adjusted the go test run step to include workspace directory change.
2024-10-27 18:22:22 +01:00
9682755e25
Delete unused .cirrus.yml configuration file
The .cirrus.yml file was removed as it is no longer needed for our CI/CD processes. This helps clean up the repository and avoids confusion over unused configurations.
2024-10-27 18:03:09 +01:00
8fb05a33ff
Update tempfile path in unit tests
Changed tempfile creation path to "testdata/tmp" for better test organization and to ensure temporary files are stored within the testdata directory. This change affects the TestMsg_AttachFile_unixOnly tests.
2024-10-27 18:02:37 +01:00
7b9df7de47
Remove harden-runner step from CI workflow
The harden-runner step has been removed from the FreeBSD testing matrix in the CI workflow. This change simplifies the workflow and removes an additional security auditing step.
2024-10-27 17:55:12 +01:00
bdffa22ad8
Remove duplicate Go test step from CI workflow
Eliminated a redundant "Run go test" step from the GitHub Actions CI configuration. This helps streamline the workflow and avoid unnecessary repetitions in the CI process.
2024-10-27 17:50:36 +01:00
89f29b241e
Add FreeBSD testing to CI workflow
Included FreeBSD versions 13.4, 14.0, and 14.1 in the CI pipeline. Configured the workflow to harden the runner, checkout code, and run tests on the FreeBSD virtual machine.
2024-10-27 17:49:04 +01:00
eed3dec7d6
Clean up redundant error checks in msg_nowin_test.go
Removed unnecessary assertions for specific error types in test cases. This streamlines the tests, maintaining focus on the primary failure conditions without checking the error type.
2024-10-27 16:19:16 +01:00
3be41b1aea
Fix chmod notation to use octal literal syntax
Updated the chmod call in msg_nowin_test.go to use the consistent and proper octal literal syntax (0o000) instead of 0000. This change improves code readability and aligns with Go convention.
2024-10-27 16:10:46 +01:00
f7cfe5289a
Remove obsolete tests and add error handling test
Removed commented-out tests to clean up the codebase. Added a new test to verify behavior when the file is closed early during attachment, ensuring robustness.
2024-10-27 16:08:50 +01:00
946ad294ce
Add tests for Msg attachment handling
Introduce new unit tests for verifying the `AttachReader` method and enhancing error handling in attachment functions. These tests cover scenarios for success, file permissions, and early file closure errors.
2024-10-27 15:54:39 +01:00
0cf636ee9b
Add test for AttachFile method and change Skip to Log
Replace t.Skip with t.Log to avoid skipping tests and ensure they log their status. Introduce a comprehensive test for the AttachFile method, covering cases with existing, non-existent files, and using options.
2024-10-27 15:28:42 +01:00
84f9d0583d
Refactor buffer initialization to use bytes.NewBuffer
Replaced direct bytes.Buffer{} initialization with bytes.NewBuffer(nil) for better consistency and potential performance improvements. This refactor affects both the HTML and plain text alternative writers.
2024-10-27 15:17:30 +01:00
254dc81706
Add tests for AddAlternativeTextTemplate method
Include various scenarios like default, with existing body string, nil template, and invalid template. These tests help in validating the addition of alternative text templates to messages.
2024-10-27 15:16:49 +01:00
e00ddda3a3
Fix test expectation and add HTML template tests
Corrected the expected number of parts in an existing test from 1 to 2. Additionally, introduced tests for adding HTML templates to message bodies, including cases with a valid template, a body string, a nil template, and an invalid template.
2024-10-27 15:13:57 +01:00
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