Example #1
0
func TestReadsEmailWithCorrectSignature(t *testing.T) {
	e := email(t, "correct_sig")

	assert.Len(t, e.Fragments, 2)
	assert.Equal(t, []bool{false, false}, quoteds(e.Fragments))
	assert.Equal(t, []bool{false, true}, signatures(e.Fragments))
	assert.Equal(t, []bool{false, true}, hiddens(e.Fragments))
	assert.Regexp(t, regexp.MustCompile("^-- \nrick"), e.Fragments[1].String())
}
Example #2
0
func TestReadsTopPost(t *testing.T) {
	e := email(t, "email_1_3")

	assert.Len(t, e.Fragments, 5)
	assert.Equal(t, []bool{false, false, true, false, false}, quoteds(e.Fragments))
	assert.Equal(t, []bool{false, true, true, true, true}, hiddens(e.Fragments))
	assert.Equal(t, []bool{false, true, false, false, true}, signatures(e.Fragments))
	assert.Regexp(t, regexp.MustCompile(`^Oh thanks.\n\nHaving`), e.Fragments[0].String())
	assert.Regexp(t, regexp.MustCompile(`^-A`), e.Fragments[1].String())
	assert.Regexp(t, regexp.MustCompile(`(?m)^On [^\:]+\:`), e.Fragments[2].String())
	assert.Regexp(t, regexp.MustCompile(`^_`), e.Fragments[4].String())
}
Example #3
0
func TestReadsBottomPost(t *testing.T) {
	e := email(t, "email_1_2")

	assert.Len(t, e.Fragments, 6)
	assert.Equal(t, []bool{false, true, false, true, false, false}, quoteds(e.Fragments))
	assert.Equal(t, []bool{false, false, false, false, false, true}, signatures(e.Fragments))
	assert.Equal(t, []bool{false, false, false, true, true, true}, hiddens(e.Fragments))
	assert.Equal(t, "Hi,", e.Fragments[0].String())
	assert.Regexp(t, regexp.MustCompile(`^On [^\:]+\:`), e.Fragments[1].String())
	assert.Regexp(t, regexp.MustCompile(`(?m)^You can list`), e.Fragments[2].String())
	assert.Regexp(t, regexp.MustCompile(`(?m)^> `), e.Fragments[3].String())
	assert.Regexp(t, regexp.MustCompile(`^_`), e.Fragments[5].String())
}
Example #4
0
func TestReadsInlineReplies(t *testing.T) {
	e := email(t, "email_1_8")

	assert.Len(t, e.Fragments, 7)
	assert.Equal(t, []bool{true, false, true, false, true, false, false}, quoteds(e.Fragments))
	assert.Equal(t, []bool{false, false, false, false, false, false, true}, signatures(e.Fragments))
	assert.Equal(t, []bool{false, false, false, false, true, true, true}, hiddens(e.Fragments))
	assert.Regexp(t, regexp.MustCompile(`^On [^\:]+\:`), e.Fragments[0].String())
	assert.Regexp(t, regexp.MustCompile(`(?m)^I will reply`), e.Fragments[1].String())
	assert.Regexp(t, regexp.MustCompile(`okay?`), e.Fragments[2].String())
	assert.Regexp(t, regexp.MustCompile(`(?m)^and under this.`), e.Fragments[3].String())
	assert.Regexp(t, regexp.MustCompile(`inline`), e.Fragments[4].String())
	assert.Equal(t, "\n", e.Fragments[5].String())
	assert.Equal(t, e.Fragments[6].String(), "--\nHey there, this is my signature\n")
}
Example #5
0
func TestReadsSimpleBody(t *testing.T) {
	e := email(t, "email_1_1")

	assert.Len(t, e.Fragments, 3)
	assert.Equal(t, []bool{false, false, false}, quoteds(e.Fragments))
	assert.Equal(t, []bool{false, true, true}, signatures(e.Fragments))
	assert.Equal(t, []bool{false, true, true}, hiddens(e.Fragments))
	assert.Equal(t, `Hi folks

What is the best way to clear a Riak bucket of all key, values after
running a test?
I am currently using the Java HTTP API.
`, e.Fragments[0].String())
	assert.Equal(t, "-Abhishek Kona\n\n", e.Fragments[1].String())
}
Example #6
0
func TestAComplexBodyWithOnlyOneFragment(t *testing.T) {
	e := email(t, "email_1_5")

	assert.Len(t, e.Fragments, 1)
}
Example #7
0
func TestDoesntRemoveSignatureDelimiterInMidLine(t *testing.T) {
	e := email(t, "email_sig_delimiter_in_middle_of_line")

	assert.Len(t, e.Fragments, 1)
}