Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram. If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

run_proxy_test.go 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package cli
  2. import (
  3. "testing"
  4. "time"
  5. "github.com/9seconds/mtg/v2/internal/config"
  6. "github.com/rs/zerolog"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. // TestMakeLoggerTimeFieldFormat verifies that the configured logTimeFormat
  10. // is what ends up in zerolog's global TimeFieldFormat — including the
  11. // historical default when the field is unset.
  12. func TestMakeLoggerTimeFieldFormat(t *testing.T) {
  13. cases := []struct {
  14. name string
  15. value string
  16. want string
  17. }{
  18. {name: "unset-default", value: "", want: zerolog.TimeFormatUnixMs},
  19. {name: "unix", value: "unix", want: zerolog.TimeFormatUnix},
  20. {name: "unix-ms", value: "unix-ms", want: zerolog.TimeFormatUnixMs},
  21. {name: "unix-micro", value: "unix-micro", want: zerolog.TimeFormatUnixMicro},
  22. {name: "unix-nano", value: "unix-nano", want: zerolog.TimeFormatUnixNano},
  23. {name: "rfc3339", value: "rfc3339", want: time.RFC3339},
  24. {name: "rfc3339-nano", value: "rfc3339-nano", want: time.RFC3339Nano},
  25. {name: "go-layout", value: "2006-01-02 15:04:05", want: "2006-01-02 15:04:05"},
  26. }
  27. for _, c := range cases {
  28. c := c
  29. t.Run(c.name, func(t *testing.T) {
  30. conf := &config.Config{}
  31. if c.value != "" {
  32. assert.NoError(t, conf.LogTimeFormat.Set(c.value))
  33. }
  34. makeLogger(conf)
  35. assert.Equal(t, c.want, zerolog.TimeFieldFormat)
  36. })
  37. }
  38. }