From 8924e426d65ca0601b552d4e2a23be6f88723c67 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Fri, 28 Jun 2024 13:49:34 +0200 Subject: [PATCH] Add test for WithFileContentID option The change introduces a new unit test, TestFile_WithContentID, in file_test.go. This test aims to verify the correct function of the WithFileContentID option by using differing scenarios, with assertions for error control and validation of expected content. --- file_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/file_test.go b/file_test.go index 8815d05..43b8cfe 100644 --- a/file_test.go +++ b/file_test.go @@ -56,6 +56,32 @@ func TestFile_WithFileDescription(t *testing.T) { } } +// TestFile_WithContentID tests the WithFileContentID option +func TestFile_WithContentID(t *testing.T) { + tests := []struct { + name string + contentid string + }{ + {"File Content-ID: test", "test"}, + {"File Content-ID: empty", ""}, + } + for _, tt := range tests { + m := NewMsg() + t.Run(tt.name, func(t *testing.T) { + m.AttachFile("file.go", WithFileContentID(tt.contentid)) + al := m.GetAttachments() + if len(al) <= 0 { + t.Errorf("AttachFile() failed. Attachment list is empty") + } + a := al[0] + if a.Header.Get(HeaderContentID.String()) != tt.contentid { + t.Errorf("WithFileContentID() failed. Expected: %s, got: %s", tt.contentid, + a.Header.Get(HeaderContentID.String())) + } + }) + } +} + // TestFile_WithFileEncoding tests the WithFileEncoding option func TestFile_WithFileEncoding(t *testing.T) { tests := []struct {