diff options
author | Koni Marti <koni.marti@gmail.com> | 2022-06-28 23:42:08 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-07-02 17:53:06 +0200 |
commit | 60052c607011ab09fe204cf5adc0cc9e29b34cdd (patch) | |
tree | da5bfd63f8aa074e4ab56353ddf32daef1c6a495 /lib/structure_helpers_test.go | |
parent | 9d90b70b4edfd2af81ac686e16f8bfd9b6ebfa9c (diff) | |
download | aerc-60052c607011ab09fe204cf5adc0cc9e29b34cdd.tar.gz |
forward: provide option to append all attachments
Append all non-multipart attachments with the -A flag. Rename the flag
for forwarding a full message as an RFC2822 attachments to -F.
Suggested-by: psykose
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'lib/structure_helpers_test.go')
-rw-r--r-- | lib/structure_helpers_test.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/structure_helpers_test.go b/lib/structure_helpers_test.go new file mode 100644 index 00000000..f670735c --- /dev/null +++ b/lib/structure_helpers_test.go @@ -0,0 +1,46 @@ +package lib_test + +import ( + "testing" + + "git.sr.ht/~rjarry/aerc/lib" + "git.sr.ht/~rjarry/aerc/models" +) + +func TestLib_FindAllNonMultipart(t *testing.T) { + + testStructure := &models.BodyStructure{ + MIMEType: "multipart", + Parts: []*models.BodyStructure{ + &models.BodyStructure{}, + &models.BodyStructure{ + MIMEType: "multipart", + Parts: []*models.BodyStructure{ + &models.BodyStructure{}, + &models.BodyStructure{}, + }, + }, + &models.BodyStructure{}, + }, + } + + expected := [][]int{ + []int{1}, + []int{2, 1}, + []int{2, 2}, + []int{3}, + } + + parts := lib.FindAllNonMultipart(testStructure, nil, nil) + + if len(expected) != len(parts) { + t.Errorf("incorrect dimensions; expected: %v, got: %v", expected, parts) + } + + for i := 0; i < len(parts); i++ { + if !lib.EqualParts(expected[i], parts[i]) { + t.Errorf("incorrect values; expected: %v, got: %v", expected[i], parts[i]) + } + } + +} |