maildir_test.go 800 B

123456789101112131415161718192021222324252627282930313233343536
  1. package fs
  2. import (
  3. "fmt"
  4. "testing"
  5. "github.com/google/go-cmp/cmp"
  6. )
  7. func TestMailFileString(t *testing.T) {
  8. clock := mockClock{}
  9. timestamp := clock.Now()
  10. progressive := 4
  11. pid := 1312
  12. hostname := "myplace"
  13. name := "main_account" // known md5sum: f2cf513ad46d4d9b9684103e468803a0
  14. uid := 33243
  15. mf := &MailFile{timestamp: timestamp, progressive: progressive, pid: pid, hostname: hostname}
  16. mf.SetFlags([]Flag{Seen, Answered})
  17. mf.SetMd5FromName(name)
  18. mf.SetUid(uid)
  19. expect := fmt.Sprintf(
  20. "%d_%d.%d.%s,U=%d,FMD5=f2cf513ad46d4d9b9684103e468803a0:2,RS",
  21. timestamp.Unix(),
  22. progressive,
  23. pid,
  24. hostname,
  25. uid)
  26. result := fmt.Sprint(mf)
  27. if expect != result {
  28. t.Errorf("Mismatch\n\tExpect: %s\n\tResult: %s\n", expect, result)
  29. t.Logf("diff: %s", cmp.Diff(expect, result))
  30. }
  31. }