utils_test.go 477 B

1234567891011121314151617181920212223242526272829303132333435
  1. package mongo
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. func TestFormatAddrs(t *testing.T) {
  7. tests := []struct {
  8. addrs []string
  9. expect string
  10. }{
  11. {
  12. addrs: []string{"a", "b"},
  13. expect: "a,b",
  14. },
  15. {
  16. addrs: []string{"a", "b", "c"},
  17. expect: "a,b,c",
  18. },
  19. {
  20. addrs: []string{},
  21. expect: "",
  22. },
  23. {
  24. addrs: nil,
  25. expect: "",
  26. },
  27. }
  28. for _, test := range tests {
  29. assert.Equal(t, test.expect, FormatAddr(test.addrs))
  30. }
  31. }