dsn_test.go 469 B

12345678910111213141516171819202122
  1. package log
  2. import (
  3. "flag"
  4. "testing"
  5. "time"
  6. xtime "go-common/library/time"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func TestUnixParseDSN(t *testing.T) {
  10. dsn := "unix:///data/log/lancer.sock?chan=1024&timeout=5s"
  11. flag.Parse()
  12. flag.Set("log.stdout", "true")
  13. as := parseDSN(dsn)
  14. assert.Equal(t, "unix", as.Proto)
  15. assert.Equal(t, "/data/log/lancer.sock", as.Addr)
  16. assert.Equal(t, 1024, as.Chan)
  17. assert.Equal(t, xtime.Duration(5*time.Second), as.Timeout)
  18. }