Esempio n. 1
0
func TestPostfixRetrieveContent(t *testing.T) {
	postfixMail := NewPostfixMail(postfixTestdata.source)
	defer postfixMail.Close()
	if err := postfixMail.Parse(); err != nil {
		t.Fatal(err)
	}

	plainTextMail := mailfile.NewPlainTextMail(postfixTestdata.plainSource)
	defer plainTextMail.Close()
	if err := plainTextMail.Parse(); err != nil {
		t.Fatal(err)
	}

	actual, err := readContentString(postfixMail.Content())
	if err != nil {
		t.Fatal(err)
	}
	actual = strings.TrimSpace(actual)

	expected, err := readContentString(plainTextMail.Content())
	if err != nil {
		t.Fatal(err)
	}
	expected = strings.TrimSpace(expected)

	if expected != actual {
		t.Fatalf("expected mail content is \n%v\n, got %v", expected, actual)
	}
}
Esempio n. 2
0
func TestPostfixRetrieveTo(t *testing.T) {
	postfixMail := NewPostfixMail(postfixTestdata.source)
	defer postfixMail.Close()
	if err := postfixMail.Parse(); err != nil {
		t.Fatal(err)
	}

	plainTextMail := mailfile.NewPlainTextMail(postfixTestdata.plainSource)
	defer plainTextMail.Close()
	if err := plainTextMail.Parse(); err != nil {
		t.Fatal(err)
	}

	if !reflect.DeepEqual(plainTextMail.To(), postfixMail.To()) {
		t.Fatalf("expected \n%v\n, got %v", plainTextMail.From(), postfixMail.From())
	}
}
Esempio n. 3
0
func TestPostfixRetrieveSubject(t *testing.T) {
	postfixMail := NewPostfixMail(postfixTestdata.source)
	defer postfixMail.Close()
	if err := postfixMail.Parse(); err != nil {
		t.Fatal(err)
	}

	plainTextMail := mailfile.NewPlainTextMail(postfixTestdata.plainSource)
	defer plainTextMail.Close()
	if err := plainTextMail.Parse(); err != nil {
		t.Fatal(err)
	}

	if plainTextMail.Subject() != postfixMail.Subject() {
		t.Fatalf("expected mail subject is %s, got %s", plainTextMail.Subject(), postfixMail.Subject())
	}
}