...
1
2
3
4
5
6
7 package address
8
9 import (
10 "testing"
11
12 "go.mongodb.org/mongo-driver/internal/require"
13 )
14
15 func TestAddress_String(t *testing.T) {
16 tests := []struct {
17 in string
18 expected string
19 }{
20 {"a", "a:27017"},
21 {"A", "a:27017"},
22 {"A:27017", "a:27017"},
23 {"a:27017", "a:27017"},
24 {"a.sock", "a.sock"},
25 }
26
27 for _, test := range tests {
28 t.Run(test.in, func(t *testing.T) {
29 require.Equal(t, Address(test.in).String(), test.expected)
30 })
31 }
32 }
33
34 func TestAddress_Canonicalize(t *testing.T) {
35 tests := []struct {
36 in string
37 expected string
38 }{
39 {"a", "a:27017"},
40 {"A", "a:27017"},
41 {"A:27017", "a:27017"},
42 {"a:27017", "a:27017"},
43 {"a.sock", "a.sock"},
44 }
45
46 for _, test := range tests {
47 t.Run(test.in, func(t *testing.T) {
48 require.Equal(t, Address(test.in).Canonicalize(), Address(test.expected))
49 })
50 }
51 }
52
View as plain text