77package options
88
99import (
10+ "fmt"
1011 "testing"
1112
1213 internalOptions "go.mongodb.org/mongo-driver/v2/internal/options"
@@ -31,7 +32,7 @@ func TestSetInternalClientOptions(t *testing.T) {
3132 for _ , tc := range cases {
3233 tc := tc
3334
34- t .Run (tc .key , func (t * testing.T ) {
35+ t .Run (fmt . Sprintf ( "set %s" , tc .key ) , func (t * testing.T ) {
3536 t .Parallel ()
3637
3738 opts := options .Client ()
@@ -42,7 +43,7 @@ func TestSetInternalClientOptions(t *testing.T) {
4243 })
4344 }
4445
45- t .Run ("crypt" , func (t * testing.T ) {
46+ t .Run ("set crypt" , func (t * testing.T ) {
4647 t .Parallel ()
4748
4849 c := driver .NewCrypt (& driver.CryptOptions {})
@@ -52,7 +53,15 @@ func TestSetInternalClientOptions(t *testing.T) {
5253 require .Equal (t , c , opts .Crypt , "expected %v, got %v" , c , opts .Crypt )
5354 })
5455
55- t .Run ("deployment" , func (t * testing.T ) {
56+ t .Run ("set crypt - wrong type" , func (t * testing.T ) {
57+ t .Parallel ()
58+
59+ opts := options .Client ()
60+ err := SetInternalClientOptions (opts , "crypt" , & drivertest.MockDeployment {})
61+ require .EqualError (t , err , "unexpected type for crypt" )
62+ })
63+
64+ t .Run ("set deployment" , func (t * testing.T ) {
5665 t .Parallel ()
5766
5867 d := & drivertest.MockDeployment {}
@@ -61,4 +70,20 @@ func TestSetInternalClientOptions(t *testing.T) {
6170 require .NoError (t , err , "error setting deployment: %v" , err )
6271 require .Equal (t , d , opts .Deployment , "expected %v, got %v" , d , opts .Deployment )
6372 })
73+
74+ t .Run ("set deployment - wrong type" , func (t * testing.T ) {
75+ t .Parallel ()
76+
77+ opts := options .Client ()
78+ err := SetInternalClientOptions (opts , "deployment" , driver .NewCrypt (& driver.CryptOptions {}))
79+ require .EqualError (t , err , "unexpected type for deployment" )
80+ })
81+
82+ t .Run ("set unsupported option" , func (t * testing.T ) {
83+ t .Parallel ()
84+
85+ opts := options .Client ()
86+ err := SetInternalClientOptions (opts , "unsupported" , "unsupported" )
87+ require .EqualError (t , err , "unsupported option: unsupported" )
88+ })
6489}
0 commit comments