From c28bd7e33193f896d6e88d5d58cb30683483a763 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Mon, 28 Oct 2024 17:42:18 +0100 Subject: [PATCH] Prevent Test Execution Without Env Variable Added a check for the "PERFORM_UNIX_OPEN_WRITE_TESTS" environment variable to conditionally skip tests. This ensures tests are only executed when the variable is set to "true". Additionally, commented out the TestMsg_WriteToTempFileFailed function. --- msg_unix_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/msg_unix_test.go b/msg_unix_test.go index 8651daf..018e215 100644 --- a/msg_unix_test.go +++ b/msg_unix_test.go @@ -94,6 +94,10 @@ func TestMsg_EmbedFile_unixOnly(t *testing.T) { func TestMsg_WriteToFile_unixOnly(t *testing.T) { t.Run("WriteToFile fails on create", func(t *testing.T) { + 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("", "testmail-create.*.eml") if err != nil { t.Fatalf("failed to create temp file: %s", err) @@ -116,6 +120,7 @@ func TestMsg_WriteToFile_unixOnly(t *testing.T) { }) } +/* func TestMsg_WriteToTempFileFailed(t *testing.T) { m := NewMsg() _ = m.From("Toni Tester ") @@ -137,3 +142,6 @@ func TestMsg_WriteToTempFileFailed(t *testing.T) { t.Errorf("WriteToTempFile() did not fail as expected") } } + + +*/