forked from emersion/go-message
-
Notifications
You must be signed in to change notification settings - Fork 0
/
header_test.go
41 lines (35 loc) · 1.41 KB
/
header_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package message
import (
"reflect"
"testing"
)
func TestHeader(t *testing.T) {
mediaType := "text/plain"
mediaParams := map[string]string{"charset": "utf-8"}
desc := "Plan de complémentarité de l'Homme"
disp := "attachment"
dispParams := map[string]string{"filename": "complémentarité.txt"}
h := make(Header)
h.SetContentType(mediaType, mediaParams)
h.SetContentDescription(desc)
h.SetContentDisposition(disp, dispParams)
if gotMediaType, gotParams, err := h.ContentType(); err != nil {
t.Error("Expected no error when parsing content type, but got:", err)
} else if gotMediaType != mediaType {
t.Errorf("Expected media type %q but got %q", mediaType, gotMediaType)
} else if !reflect.DeepEqual(gotParams, mediaParams) {
t.Errorf("Expected media params %v but got %v", mediaParams, gotParams)
}
if gotDesc, err := h.ContentDescription(); err != nil {
t.Error("Expected no error when parsing content description, but got:", err)
} else if gotDesc != desc {
t.Errorf("Expected content description %q but got %q", desc, gotDesc)
}
if gotDisp, gotParams, err := h.ContentDisposition(); err != nil {
t.Error("Expected no error when parsing content disposition, but got:", err)
} else if gotDisp != disp {
t.Errorf("Expected disposition %q but got %q", disp, gotDisp)
} else if !reflect.DeepEqual(gotParams, dispParams) {
t.Errorf("Expected disposition params %v but got %v", dispParams, gotParams)
}
}