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