Exemplo n.º 1
0
func (s *ProcessSuite) TestCustomizedProcess(c *C) {
	file := "japanese"
	input, err := ioutil.ReadFile("input/" + file + ".eml")
	if err != nil {
		c.Fatal(err)
	}
	maincontent, _ := ioutil.ReadFile("output/" + file + "_customized_main.html")
	othercontent, _ := ioutil.ReadFile("output/" + file + "_customized_other.html")

	newMaincontent := string(maincontent)
	if mailthread.HasLeadingNestedMailArrow(string(maincontent)) {
		newMaincontent, err = mailthread.RemoveLeadingNestedArrows(string(maincontent))
		if err != nil {
			c.Fatal(err)
		}
	}
	newOthercontent := string(othercontent)
	if mailthread.HasLeadingNestedMailArrow(string(othercontent)) {
		newOthercontent, err = mailthread.RemoveLeadingNestedArrows(string(othercontent))
		if err != nil {
			c.Fatal(err)
		}
	}

	ch := &CustomizedContentHandler{}
	mailthread.ProcessStringWithHandler(string(input), ch)

	c.Check(ch.mainContent.String(), Equals, newMaincontent)
	c.Check(ch.otherContent.String(), Equals, newOthercontent)
}
Exemplo n.º 2
0
func (s *ProcessSuite) TestGoThoughProcess(c *C) {
	for _, file := range testFiles {
		input, err := ioutil.ReadFile("input/" + file + ".eml")
		if err != nil {
			c.Fatal(err)
		}

		processedInput := mailthread.ProcessStringWithHandler(string(input), &mailthread.GoThroughHandler{})

		newInput := string(input)
		if mailthread.HasLeadingNestedMailArrow(string(input)) {
			newInput, err = mailthread.RemoveLeadingNestedArrows(string(input))
			if err != nil {
				c.Fatal(err)
			}
		}

		c.Log("TEST FILE: ", file)
		c.Check(processedInput, Equals, newInput)
	}
}