2022-06-28 23:42:08 +02:00
|
|
|
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{
|
2022-07-31 22:16:40 +02:00
|
|
|
{},
|
|
|
|
{
|
2022-06-28 23:42:08 +02:00
|
|
|
MIMEType: "multipart",
|
|
|
|
Parts: []*models.BodyStructure{
|
2022-07-31 22:16:40 +02:00
|
|
|
{},
|
|
|
|
{},
|
2022-06-28 23:42:08 +02:00
|
|
|
},
|
|
|
|
},
|
2022-07-31 22:16:40 +02:00
|
|
|
{},
|
2022-06-28 23:42:08 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
expected := [][]int{
|
2022-07-31 22:16:40 +02:00
|
|
|
{1},
|
|
|
|
{2, 1},
|
|
|
|
{2, 2},
|
|
|
|
{3},
|
2022-06-28 23:42:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|