@@ -10,6 +10,7 @@ import (
10
10
"fmt"
11
11
"net/url"
12
12
"testing"
13
+ "time"
13
14
14
15
"github.com/stretchr/testify/assert"
15
16
"go.mongodb.org/mongo-driver/mongo/options"
@@ -80,3 +81,26 @@ func TestLoadBalancedFromConnString(t *testing.T) {
80
81
})
81
82
}
82
83
}
84
+
85
+ func TestTopologyNewConfig (t * testing.T ) {
86
+ t .Run ("default ServerSelectionTimeout" , func (t * testing.T ) {
87
+ cfg , err := NewConfig (options .Client (), nil )
88
+ assert .Nil (t , err , "error constructing topology config: %v" , err )
89
+ assert .Equal (t , defaultServerSelectionTimeout , cfg .ServerSelectionTimeout )
90
+ })
91
+ t .Run ("non-default ServerSelectionTimeout" , func (t * testing.T ) {
92
+ cfg , err := NewConfig (options .Client ().SetServerSelectionTimeout (1 ), nil )
93
+ assert .Nil (t , err , "error constructing topology config: %v" , err )
94
+ assert .Equal (t , time .Duration (1 ), cfg .ServerSelectionTimeout )
95
+ })
96
+ t .Run ("default SeedList" , func (t * testing.T ) {
97
+ cfg , err := NewConfig (options .Client (), nil )
98
+ assert .Nil (t , err , "error constructing topology config: %v" , err )
99
+ assert .Equal (t , []string {"localhost:27017" }, cfg .SeedList )
100
+ })
101
+ t .Run ("non-default SeedList" , func (t * testing.T ) {
102
+ cfg , err := NewConfig (options .Client ().ApplyURI ("mongodb://localhost:27018" ), nil )
103
+ assert .Nil (t , err , "error constructing topology config: %v" , err )
104
+ assert .Equal (t , []string {"localhost:27018" }, cfg .SeedList )
105
+ })
106
+ }
0 commit comments