Skip to content
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
wants to merge 96 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
2088796
Remove testdata directory and extra newline from .gitignore
wneessen Oct 23, 2024
946d988
Refactor error handling in Base64LineBreaker
wneessen Oct 23, 2024
bdfe13d
Overhauled Base64LineBreaker test suite
wneessen Oct 23, 2024
421451f
Add base64-encoded logo.svg to testdata
wneessen Oct 23, 2024
8543610
Add coverage files to .gitignore
wneessen Oct 23, 2024
b31c7cf
Add licenses for logo SVG files
wneessen Oct 23, 2024
0bac517
Add error handling for base64 decoding in test
wneessen Oct 23, 2024
ab835b7
Uncomment seed data in FuzzBase64LineBreaker
wneessen Oct 23, 2024
1c8b290
Add error check for nil SMTP authentication method
wneessen Oct 23, 2024
3251d74
Refactor client test to enhance coverage and clarity
wneessen Oct 23, 2024
35f92f2
Add error handling for nil DialContextFunc
wneessen Oct 23, 2024
ab8fc3e
Add DSN and dial context func options to client tests
wneessen Oct 23, 2024
c5b5754
Update client tests to add context support and new checks
wneessen Oct 23, 2024
3efd2b5
Set fallbackPort to 0 in SetTLSPortPolicy
wneessen Oct 23, 2024
68bc5dd
Add comprehensive tests for Client TLS and debugging features
wneessen Oct 23, 2024
c946f74
Add unit tests for Client TLS, Username, and Password methods
wneessen Oct 23, 2024
17cb590
Add test for Client.SetSMTPAuth function
wneessen Oct 23, 2024
d4dc212
Refactor client tests and add SetSMTPAuthCustom test
wneessen Oct 23, 2024
ae7160d
Refactor SMTP Auth unit test with table-driven approach
wneessen Oct 23, 2024
8a6cd2b
Add and update client tests
wneessen Oct 23, 2024
1269538
Refactor SMTP server test setup to use serverProps struct
wneessen Oct 23, 2024
21184e6
Switch to using bytes.NewBuffer(nil) in tests
wneessen Oct 23, 2024
0db1383
Refactor buffer initialization in client tests
wneessen Oct 23, 2024
d281f83
Add integration tests for invalid host and HELO failure
wneessen Oct 23, 2024
572751a
Add test for invalid HELO handling in SMTP client
wneessen Oct 23, 2024
74fa3f6
Fix Quit handling when initial HELO fails
wneessen Oct 23, 2024
ea57644
Add debug logging to client creation in tests
wneessen Oct 23, 2024
563ccba
Fix typo in comment within Quit function
wneessen Oct 23, 2024
c63b8b1
Add STARTTLS and SSL test cases for SMTP client
wneessen Oct 23, 2024
cf1246d
Remove redundant DialWithContext test cases
wneessen Oct 23, 2024
7f3cd8d
Merge branch 'main' into feature/overhaul-tests
wneessen Oct 23, 2024
2710250
Add *testing.T to simpleSMTPServer and logging improvements
wneessen Oct 23, 2024
06f6fd3
Add client reset functionality tests
wneessen Oct 23, 2024
84ca700
Add test for DialAndSend functionality
wneessen Oct 23, 2024
28dc629
Refactor and expand client dial-and-send tests
wneessen Oct 23, 2024
e442419
Remove redundant connection check in tls function
wneessen Oct 24, 2024
2a2176d
Add tests for various SMTP authentication methods
wneessen Oct 24, 2024
040289c
Remove hardcoded test credentials and add new auth tests.
wneessen Oct 24, 2024
5e3ebcc
Remove redundant connection check in auth function
wneessen Oct 24, 2024
4a8ac76
Add nil check for smtpClient in checkConn function
wneessen Oct 24, 2024
3bf1992
Improve test conciseness and concurrency handling
wneessen Oct 24, 2024
1519522
Reduce sleep duration in client tests
wneessen Oct 24, 2024
45ebcb9
Remove redundant connection check in send function.
wneessen Oct 24, 2024
1399a33
Refactor and extend client email tests
wneessen Oct 24, 2024
0310527
Completed client.go tests
wneessen Oct 24, 2024
7ed23bf
Remove outdated client test cases
wneessen Oct 24, 2024
127cfdf
Fix error variable declaration in eml.go
wneessen Oct 24, 2024
887e3cd
Add EML parsing with new tests and examples
wneessen Oct 24, 2024
9f1e197
Fix assignment in error handling for EML parsing function
wneessen Oct 24, 2024
769783f
Refactor error handling in eml parser
wneessen Oct 24, 2024
75e035c
Add test cases for various EML parsing scenarios
wneessen Oct 24, 2024
9834c65
Refactor file_test.go to use subtests
wneessen Oct 24, 2024
8353b4b
Follow upstream for HELO during Quit bug
wneessen Oct 25, 2024
eebbaa2
Refactor and reintegrate content type tests in file_test.go
wneessen Oct 25, 2024
c58d52e
Refactor TestImportance_StringFuncs in header_test.go
wneessen Oct 25, 2024
64cfbf9
Rename test functions and add new header cases.
wneessen Oct 25, 2024
c4946af
Refactor msg_test.go to streamline tests and reduce redundancy
wneessen Oct 25, 2024
120c2ef
Refactor test cases with shared test data
wneessen Oct 25, 2024
1dba769
Simplify test descriptions in msg_test.go
wneessen Oct 25, 2024
64aeb68
Format test cases for consistency
wneessen Oct 25, 2024
425a190
fumpt'ed formatting
wneessen Oct 25, 2024
69c5f43
Refactor test cases in header_test.go
wneessen Oct 25, 2024
a2e9dba
Add unit tests for charset and header setting in messages
wneessen Oct 25, 2024
143e3b5
Fix context in tests and improve error handling
wneessen Oct 25, 2024
9505f94
Refactor header test structure and improve readability
wneessen Oct 25, 2024
7d352bc
Add comprehensive tests for header and address methods
wneessen Oct 25, 2024
08fe44c
Initialize address header map and enforce single 'From' address.
wneessen Oct 25, 2024
c8dbc9a
Update tests for SetAddrHeader and add new test cases
wneessen Oct 25, 2024
1caa2cf
Add tests for EnvelopeFrom and EnvelopeFromFormat methods
wneessen Oct 25, 2024
5d85be0
Add comprehensive tests for email "From" field validation
wneessen Oct 25, 2024
aa46b40
Add additional tests for From and To address handling
wneessen Oct 25, 2024
cb85a13
Add Goland noinspection comments to suppress deprecation warnings
wneessen Oct 25, 2024
a7f81ba
Fix address references in tests and add AddTo functionality
wneessen Oct 25, 2024
1ea7b17
Add tests for Msg.AddToFormat
wneessen Oct 25, 2024
8b6a792
Add dummy test function in msg_test.go
wneessen Oct 25, 2024
03da20f
Add unit tests for Msg_ToIgnoreInvalid behavior
wneessen Oct 25, 2024
c99b6c3
Fix ToFromString to handle and trim empty addresses
wneessen Oct 25, 2024
e08d36d
Refactor address header validation in tests
wneessen Oct 25, 2024
3a3eaed
Refactor address header tests to use `checkAddrHeader`
wneessen Oct 26, 2024
0e9646e
Merge branch 'main' into feature/overhaul-tests
wneessen Oct 26, 2024
9e6c1f0
Consolidate CI workflows into a single file
wneessen Oct 26, 2024
12e9a0c
Simplify CI workflow branch checks
wneessen Oct 26, 2024
960c015
Remove IPv6 and IPv4 test cases from msg_test.go
wneessen Oct 26, 2024
4d4aa1e
Add runs-on parameter to dependency review job
wneessen Oct 26, 2024
9c57ba5
Add 'runs-on' directive to lint and govulncheck steps
wneessen Oct 26, 2024
eeccee0
Add checkout step to CI workflow
wneessen Oct 26, 2024
f82ac0c
Update concurrency group names in GitHub Actions
wneessen Oct 26, 2024
3aef85e
Add SPDX license headers to CI workflow file
wneessen Oct 26, 2024
9072aef
Remove support for Go 1.19 and 1.20 in CI workflow
wneessen Oct 26, 2024
4b8bf05
Update CI workflow and sendmail test condition
wneessen Oct 26, 2024
c33900c
Add sudo to apt-get commands in CI workflow
wneessen Oct 26, 2024
a815c58
Update CI workflow to install nullmailer instead of ssmtp
wneessen Oct 26, 2024
273a26c
Add tests for Go 1.21+ compatibility
wneessen Oct 26, 2024
90e3162
Update CI to support older Go versions
wneessen Oct 26, 2024
23399ed
Change DefaultHost to loopback address
wneessen Oct 26, 2024
d7b3248
Handle test server connection timeouts
wneessen Oct 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 195 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
# SPDX-FileCopyrightText: 2024 The go-mail Authors
#
# SPDX-License-Identifier: MIT

name: CI

permissions:
contents: read

on:
push:
branches:
- main
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}

jobs:
codecov:
name: Test with Codecov coverage (${{ matrix.os }} / ${{ matrix.go }})
runs-on: ${{ matrix.os }}
concurrency:
group: ci-codecov-${{ matrix.os }}-${{ matrix.go }}
cancel-in-progress: true
strategy:
matrix:
os: [ubuntu-latest]
go: ['1.23']
env:
PERFORM_ONLINE_TEST: ${{ vars.PERFORM_ONLINE_TEST }}
TEST_SENDMAIL: ${{ vars.TEST_SENDMAIL }}
TEST_HOST: ${{ secrets.TEST_HOST }}
TEST_USER: ${{ secrets.TEST_USER }}
TEST_PASS: ${{ secrets.TEST_PASS }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@61b9e3751b92087fd0b06925ba6dd6314e06f089 # master
- name: Setup go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: ${{ matrix.go }}
check-latest: true
- name: Install sendmail
run: |
sudo apt-get -y update >/dev/null && sudo apt-get -y upgrade >/dev/null && sudo DEBIAN_FRONTEND=noninteractive apt-get -y install nullmailer >/dev/null && which sendmail
- name: Run go test
if: success()
run: |
go test -race -shuffle=on --coverprofile=coverage.coverprofile --covermode=atomic ./...
- name: Upload coverage to Codecov
if: success()
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
lint:
name: golangci-lint (${{ matrix.go }})
runs-on: ubuntu-latest
concurrency:
group: ci-lint-${{ matrix.go }}
cancel-in-progress: true
strategy:
matrix:
go: ['1.23']
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Setup go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: ${{ matrix.go }}
check-latest: true
- name: Checkout Code
uses: actions/checkout@61b9e3751b92087fd0b06925ba6dd6314e06f089 # master
- name: golangci-lint
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
with:
version: latest
dependency-review:
name: Dependency review
runs-on: ubuntu-latest
concurrency:
group: ci-dependency-review
cancel-in-progress: true
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@61b9e3751b92087fd0b06925ba6dd6314e06f089 # master
- name: 'Dependency Review'
uses: actions/dependency-review-action@a6993e2c61fd5dc440b409aa1d6904921c5e1894 # v4.3.5
govulncheck:
name: Go vulnerabilities check
runs-on: ubuntu-latest
concurrency:
group: ci-govulncheck
cancel-in-progress: true
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Run govulncheck
uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # v1.0.4
test:
name: Test (${{ matrix.os }} / ${{ matrix.go }})
runs-on: ${{ matrix.os }}
concurrency:
group: ci-test-${{ matrix.os }}-${{ matrix.go }}
cancel-in-progress: true
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go: ['1.19', '1.20', '1.21', '1.22', '1.23']
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@61b9e3751b92087fd0b06925ba6dd6314e06f089 # master
- name: Setup go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: ${{ matrix.go }}
- name: Run go test
run: |
go test -race -shuffle=on ./...
reuse:
name: REUSE Compliance Check
runs-on: ubuntu-latest
concurrency:
group: ci-reuse
cancel-in-progress: true
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@61b9e3751b92087fd0b06925ba6dd6314e06f089 # master
- name: REUSE Compliance Check
uses: fsfe/reuse-action@3ae3c6bdf1257ab19397fab11fd3312144692083 # v4.0.0
sonarqube:
name: Test with SonarQube review (${{ matrix.os }} / ${{ matrix.go }})
runs-on: ${{ matrix.os }}
concurrency:
group: ci-codecov-${{ matrix.go }}
cancel-in-progress: true
strategy:
matrix:
os: [ubuntu-latest]
go: ['1.23']
env:
PERFORM_ONLINE_TEST: ${{ vars.PERFORM_ONLINE_TEST }}
TEST_HOST: ${{ secrets.TEST_HOST }}
TEST_USER: ${{ secrets.TEST_USER }}
TEST_PASS: ${{ secrets.TEST_PASS }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout Code
uses: actions/checkout@61b9e3751b92087fd0b06925ba6dd6314e06f089 # master
- name: Setup go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: ${{ matrix.go }}
check-latest: true
- name: Run go test
run: |
go test -shuffle=on -race --coverprofile=./cov.out ./...
- name: SonarQube scan
uses: sonarsource/sonarqube-scan-action@884b79409bbd464b2a59edc326a4b77dc56b2195 # master
if: success()
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- name: SonarQube quality gate
uses: sonarsource/sonarqube-quality-gate-action@dc2f7b0dd95544cd550de3028f89193576e958b9 # master
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
67 changes: 0 additions & 67 deletions .github/workflows/codecov.yml

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflows/dependency-review.yml

This file was deleted.

54 changes: 0 additions & 54 deletions .github/workflows/golangci-lint.yml

This file was deleted.

21 changes: 0 additions & 21 deletions .github/workflows/govulncheck.yml

This file was deleted.

Loading
Loading