(t *testing.T)
| 35 | } |
| 36 | |
| 37 | func TestAttachments_OrderAndDecode(t *testing.T) { |
| 38 | atts := Attachments(sampleMultipart()) |
| 39 | if len(atts) != 2 { |
| 40 | t.Fatalf("want 2 attachments (text body excluded), got %d: %+v", len(atts), atts) |
| 41 | } |
| 42 | if atts[0].Filename != "report.pdf" || atts[0].ContentType != "application/pdf" { |
| 43 | t.Errorf("att0 meta wrong: %+v", atts[0]) |
| 44 | } |
| 45 | if string(atts[0].Data) != "%PDF-1.4 fake pdf bytes" { |
| 46 | t.Errorf("att0 bytes not decoded: %q", atts[0].Data) |
| 47 | } |
| 48 | if atts[1].Filename != "logo.png" || atts[1].ContentType != "image/png" { |
| 49 | t.Errorf("att1 meta wrong: %+v", atts[1]) |
| 50 | } |
| 51 | if !bytes.Equal(atts[1].Data, []byte("\x89PNG\r\n fake png")) { |
| 52 | t.Errorf("att1 binary bytes not decoded: %q", atts[1].Data) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | func TestAttachmentAt_Bounds(t *testing.T) { |
| 57 | raw := sampleMultipart() |
nothing calls this directly
no test coverage detected