action_test.go 883 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package pop3_server
  2. import (
  3. "bytes"
  4. "fmt"
  5. "github.com/Jinnrry/gopop"
  6. "github.com/Jinnrry/pmail/config"
  7. "github.com/Jinnrry/pmail/db"
  8. "github.com/Jinnrry/pmail/utils/context"
  9. "github.com/emersion/go-message/mail"
  10. "io"
  11. "testing"
  12. )
  13. func Test_action_Retr(t *testing.T) {
  14. config.Init()
  15. db.Init("")
  16. a := action{}
  17. session := &gopop.Session{
  18. Ctx: &context.Context{
  19. UserID: 1,
  20. },
  21. }
  22. got, got1, err := a.Retr(session, 301)
  23. _, _, _ = got, got1, err
  24. }
  25. func Test_email(t *testing.T) {
  26. var b bytes.Buffer
  27. // Create our mail header
  28. var h mail.Header
  29. // Create a new mail writer
  30. mw, _ := mail.CreateWriter(&b, h)
  31. // Create a text part
  32. tw, _ := mw.CreateInline()
  33. var html mail.InlineHeader
  34. html.Header.Set("Content-Transfer-Encoding", "base64")
  35. w, _ := tw.CreatePart(html)
  36. io.WriteString(w, "=")
  37. w.Close()
  38. tw.Close()
  39. fmt.Printf("%s", b.String())
  40. }