-
-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overhaul test cases and github test workflow #347
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The testdata directory entry was incorrect and has been removed. Additionally, an extra newline at the end of the file was removed for consistency.
Switched ErrNoOutWriter from a string constant to an error object for improved error handling consistency. This change enhances clarity and reduces the risk of error handling inconsistencies in the future.
Improved the test suite for the Base64LineBreaker. Tests are now written more consistently. Maintainability and readability have been improved as well.
This commit introduces a new file, logo.svg.base64, into the testdata directory. This encoded SVG logo will be useful for testing purposes.
This change ensures that coverage data files are not tracked by Git. The addition helps keep the repository clean from auto-generated coverage reports.
These files specify the copyright and licensing information for the logo assets. They ensure that our usage of these images complies with the CC-BY-ND-4.0 license.
This commit adds a check for errors when decoding base64 strings in the b64linebreaker_test.go file. If an error occurs, it logs a meaningful error message, improving the test's robustness and clarity.
The previously commented-out empty byte array is now uncommented to include an empty string as part of the test cases. This change ensures that the FuzzBase64LineBreaker function properly handles an empty input scenario.
Ensure that the SMTP authentication method is not nil by adding a corresponding error check in the WithSMTPAuthCustom function. Introduced a new error, ErrSMTPAuthMethodIsNil, to handle this validation.
Reorganized and refactored tests for `NewClient` by adding individual test cases for different client creation scenarios, including various options and validation. Improved clarity and coverage by isolating cases, enhancing error messages, and removing redundancy.
Introduce ErrDialContextFuncIsNil to handle cases where the dial context function is not provided. Update WithDialContextFunc to return this error when a nil function is passed.
Expanded the client test cases to include DSN mail return types and multiple DSN recipient notify types. Also added tests for setting dial context functions using both net.Dialer and tls.Dialer, including error handling for invalid options.
Introduced `context` package for new tests. Added checks for `WithDialContextFunc`, `WithLogAuthData`, and TLS policy assertions. Improved test failure handling and removed obsolete tests.
The default fallback port should be reset to 0 when setting the TLS port policy. This ensures the fallbackPort does not retain an incorrect value when switching policies.
Implemented detailed test cases for various TLS policies and settings, port configurations, and SSL options. Also added tests for debugging functionalities of the Client, enabling robust validation of different scenarios.
Introduced unit tests for Client's SetTLSConfig, SetUsername, and SetPassword methods. The tests cover various scenarios, including setting valid configurations, handling nil inputs, and overriding previous settings. This improves our test coverage and ensures the reliability of these methods.
Introduce a new test to validate the functionality of the Client.SetSMTPAuth method. This test covers various SMTP authentication types and ensures that the method correctly sets the expected authentication type while also verifying the override behavior for different custom and default authentications.
Removed outdated tests for TLSConfig, Username, Password, and SMTPAuth that were commented out. Added a new test for the SetSMTPAuthCustom method, specifically for PLAIN authentication, ensuring proper behavior and type checks.
Replaced the single test case for setting custom SMTP authentication with a table-driven approach. This refactor improves test coverage by including multiple authentication methods such as CRAM-MD5, LOGIN, PLAIN, SCRAM, and XOAUTH2.
Reintroduces and enhances several client tests including `SetLogAuthData`, `Close`, `DialWithContext`, and others. Deprecated and non-functional tests are removed, and a new log parsing method is added for enhanced logging validation.
Consolidate server configuration properties into a new serverProps struct for better code clarity and future extensibility. This change involves updating simpleSMTPServer and test cases to use the new struct, allowing more control over server behavior during tests.
Refactored the test code to initialize buffers using bytes.NewBuffer(nil) instead of &bytes.Buffer{}. This change ensures a consistent and idiomatic initialization of byte buffers throughout the test cases.
Replaced &bytes.Buffer{} with bytes.NewBuffer(nil) for buffer initialization in various client tests. This change ensures more idiomatic and consistent creation of byte buffers throughout the test cases.
Add test cases to validate client behavior on connecting with an invalid host and encountering a HELO failure. This helps ensure the client handles these error scenarios correctly, maintaining robustness and reliability.
Introduce a new test case to ensure the SMTP client fails gracefully when an invalid HELO command is used. This includes validating error handling and maintaining the client connection integrity. Also, optimize EHLO/HELO command handling by enhancing syntax checking and error response generation.
Ensure QUIT command can be sent even if initial HELO fails. Added a check to skip retrying HELO if it already failed, allowing for proper closing of the connection. This prevents potential hangs or errors during connection termination.
Introduce `WithDebugLog()` in client creation for enhanced logging during tests. Correct handling of certain SMTP command errors by replacing `return` with `break` in switch cases for proper loop continuation.
Corrected grammar in a comment to enhance code readability and maintain consistency. This change does not affect the functionality of the `Quit` method.
Extended test cases to include scenarios for STARTTLS and SSL connections. This includes handling TLS configurations, testing certificate handling, and tests for various authentication methods under TLS.
Deleted two test functions for DialWithContext that tested invalid HELO and authentication scenarios. These tests were deemed redundant as the error handling for these cases is covered elsewhere.
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.
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.
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.
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.
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.
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.
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.
Previously, the ToFromString function split email addresses by commas but did not handle empty addresses or trim whitespace. Now, it trims each address and ignores any empty entries to ensure only valid addresses are processed. This prevents potential errors stemming from malformed input.
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.
Consolidate repeated header validation logic into the `checkAddrHeader` helper function. This refactoring improves code readability and maintainability by reducing redundancy and potential for errors.
Merged separate workflows for Codecov, dependency-review, golangci-lint, govulncheck, offline-tests, reuse compliance, and SonarQube into a unified CI workflow file in `.github/workflows/ci.yml`. This restructuring simplifies our CI setup and ensures more consistent and efficient pipeline management.
Removed file path filters on branch triggers in the CI workflow configuration. This allows the CI to run for any changes made in the main branch, ensuring broader test coverage and catching issues early.
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.
This change specifies that the dependency review job should run on the latest version of Ubuntu. It ensures consistency and clarity in the workflow configuration. This modification helps avoid potential issues related to unspecified runner environments.
This ensures the lint and vulnerability check steps run on the 'ubuntu-latest' environment. Establishing a clear execution environment helps maintain consistency across CI runs.
Ensure CI workflow has access to the latest code by adding a checkout step. This change is necessary for the golangci-lint action to function correctly with the most recent codebase.
This change modifies the concurrency group names to include OS and Go version for better differentiation. This prevents conflicts and ensures that concurrent jobs are properly managed based on their specific matrices.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #347 +/- ##
==========================================
- Coverage 84.09% 76.65% -7.45%
==========================================
Files 27 27
Lines 2918 2930 +12
==========================================
- Hits 2454 2246 -208
- Misses 332 590 +258
+ Partials 132 94 -38 ☔ View full report in Codecov by Sentry. |
This change adds SPDX license headers to the .github/workflows/ci.yml file to ensure proper attribution and compliance with the MIT license. The added headers include copyright information and the applicable license type.
This commit updates the CI configuration to no longer test against Go versions 1.19 and 1.20. The supported Go versions are now 1.21, 1.22, and 1.23, ensuring the CI pipeline aligns with our current support policy.
Add the TEST_SENDMAIL environment variable for better control over sendmail tests. Optimize sendmail installation in CI by updating and installing ssmtp. Modify tests to check if TEST_SENDMAIL is set to "true" before running.
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.
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.
Moved some tests that use JSONlog (which requires Go 1.21+) to a separate file that is skipped on 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.
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".
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR improves the overall test suite of go-mail. All tests have been reworked and improved code readability and maintainability by reducing redundancy.
Still WIP.
During the refactoring the following bugs were found and fixed: