Compare commits

..

4 commits

Author SHA1 Message Date
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
2 changed files with 16 additions and 8 deletions

View file

@ -31,6 +31,7 @@ jobs:
go: ['1.23'] go: ['1.23']
env: env:
PERFORM_ONLINE_TEST: ${{ vars.PERFORM_ONLINE_TEST }} PERFORM_ONLINE_TEST: ${{ vars.PERFORM_ONLINE_TEST }}
PERFORM_UNIX_OPEN_WRITE_TESTS: "true"
TEST_SENDMAIL: ${{ vars.TEST_SENDMAIL }} TEST_SENDMAIL: ${{ vars.TEST_SENDMAIL }}
TEST_HOST: ${{ secrets.TEST_HOST }} TEST_HOST: ${{ secrets.TEST_HOST }}
TEST_USER: ${{ secrets.TEST_USER }} TEST_USER: ${{ secrets.TEST_USER }}
@ -144,7 +145,7 @@ jobs:
cancel-in-progress: true cancel-in-progress: true
strategy: strategy:
matrix: matrix:
osver: ['13.4', '14.0', '14.1'] osver: ['14.1', '14.0', 13.4']
steps: steps:
- name: Checkout Code - name: Checkout Code
uses: actions/checkout@61b9e3751b92087fd0b06925ba6dd6314e06f089 # master uses: actions/checkout@61b9e3751b92087fd0b06925ba6dd6314e06f089 # master
@ -152,9 +153,11 @@ jobs:
uses: vmactions/freebsd-vm@v1 uses: vmactions/freebsd-vm@v1
with: with:
usesh: true usesh: true
copyback: false
prepare: | prepare: |
pkg install -y go pkg install -y go
run: | run: |
cd $GITHUB_WORKSPACE;
go test -race -shuffle=on ./... go test -race -shuffle=on ./...
reuse: reuse:
name: REUSE Compliance Check name: REUSE Compliance Check

View file

@ -2,8 +2,8 @@
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
//go:build !windows //go:build linux || freebsd
// +build !windows // +build linux freebsd
package mail package mail
@ -18,23 +18,28 @@ import (
func TestMsg_AttachFile_unixOnly(t *testing.T) { func TestMsg_AttachFile_unixOnly(t *testing.T) {
t.Run("AttachFile with fileFromFS fails on open", func(t *testing.T) { t.Run("AttachFile with fileFromFS fails on open", func(t *testing.T) {
tempfile, err := os.CreateTemp("testdata/tmp", "attachfile-unable-to-open.*.txt") if os.Getenv("PERFORM_UNIX_OPEN_WRITE_TESTS") != "true" {
t.Skipf("PERFORM_UNIX_OPEN_WRITE_TESTS variable is not set. Skipping unix open/write tests")
}
tempFile, err := os.CreateTemp("testdata/tmp", "attachfile-open-write-test.*.txt")
if err != nil { if err != nil {
t.Fatalf("failed to create temp file: %s", err) t.Fatalf("failed to create temp file: %s", err)
} }
t.Cleanup(func() { t.Cleanup(func() {
if err := os.Remove(tempfile.Name()); err != nil { if err := os.Remove(tempFile.Name()); err != nil {
t.Errorf("failed to remove temp file: %s", err) t.Errorf("failed to remove temp file: %s", err)
} }
}) })
if err = os.Chmod(tempfile.Name(), 0o000); err != nil { if err = os.Chmod(tempFile.Name(), 0o000); err != nil {
t.Fatalf("failed to chmod temp file to 0000: %s", err) t.Fatalf("failed to chmod temp file: %s", err)
} }
message := NewMsg() message := NewMsg()
if message == nil { if message == nil {
t.Fatal("message is nil") t.Fatal("message is nil")
} }
message.AttachFile(tempfile.Name()) message.AttachFile(tempFile.Name())
attachments := message.GetAttachments() attachments := message.GetAttachments()
if len(attachments) != 1 { if len(attachments) != 1 {
t.Fatalf("failed to get attachments, expected 1, got: %d", len(attachments)) t.Fatalf("failed to get attachments, expected 1, got: %d", len(attachments))