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

	assert.Regexp(t, regexp.MustCompile(`:\+1:`), e.Fragments[0].String())
	assert.Regexp(t, regexp.MustCompile(`(?m)^On`), e.Fragments[1].String())
	assert.Regexp(t, regexp.MustCompile(`Steps 0-2`), e.Fragments[1].String())
}
Example #2
0
func TestDealsWithMultilineReplyHeaders(t *testing.T) {
	e := email(t, "email_1_6")

	assert.Regexp(t, regexp.MustCompile(`^I get`), e.Fragments[0].String())
	assert.Regexp(t, regexp.MustCompile(`(?m)^On`), e.Fragments[1].String())
	assert.Regexp(t, regexp.MustCompile(`Was this`), e.Fragments[1].String())
}
Example #3
0
func TestRecognizesDateStringAboveQuote(t *testing.T) {
	e := email(t, "email_1_4")

	assert.Regexp(t, regexp.MustCompile(`^Awesome`), e.Fragments[0].String())
	assert.Regexp(t, regexp.MustCompile(`(?m)^On`), e.Fragments[1].String())
	assert.Regexp(t, regexp.MustCompile(`Loader`), e.Fragments[1].String())
}
Example #4
0
func TestMultipleOn(t *testing.T) {
	e := email(t, "greedy_on")

	assert.Regexp(t, regexp.MustCompile(`(?m)^On your remote host`), e.Fragments[0].String())
	assert.Regexp(t, regexp.MustCompile(`(?m)^On 9 Jan 2014`), e.Fragments[1].String())
	assert.Equal(t, []bool{false, true, false}, quoteds(e.Fragments))
	assert.Equal(t, []bool{false, false, false}, signatures(e.Fragments))
	assert.Equal(t, []bool{false, true, true}, hiddens(e.Fragments))

}
Example #5
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 #6
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 #7
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 #8
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 #9
0
func TestOneIsNotOn(t *testing.T) {
	e := email(t, "email_one_is_not_on")

	assert.Regexp(t, regexp.MustCompile(`One outstanding question`), e.Fragments[0].String())
	assert.Regexp(t, regexp.MustCompile(`(?m)^On Oct 1, 2012`), e.Fragments[1].String())
}