@@ -31,91 +31,91 @@ func TestAtlas(t *testing.T) {
3131 name string
3232 envVar string
3333 certKeyFile string
34- wantErrCode string
34+ wantErr string
3535 }{
3636 {
3737 name : "Atlas with TLS" ,
3838 envVar : "ATLAS_REPL" ,
3939 certKeyFile : "" ,
40- wantErrCode : "" ,
40+ wantErr : "" ,
4141 },
4242 {
4343 name : "Atlas with TLS and shared cluster" ,
4444 envVar : "ATLAS_SHRD" ,
4545 certKeyFile : "" ,
46- wantErrCode : "" ,
46+ wantErr : "" ,
4747 },
4848 {
4949 name : "Atlas with free tier" ,
5050 envVar : "ATLAS_FREE" ,
5151 certKeyFile : "" ,
52- wantErrCode : "" ,
52+ wantErr : "" ,
5353 },
5454 {
5555 name : "Atlas with TLS 1.1" ,
5656 envVar : "ATLAS_TLS11" ,
5757 certKeyFile : "" ,
58- wantErrCode : "" ,
58+ wantErr : "" ,
5959 },
6060 {
6161 name : "Atlas with TLS 1.2" ,
6262 envVar : "ATLAS_TLS12" ,
6363 certKeyFile : "" ,
64- wantErrCode : "" ,
64+ wantErr : "" ,
6565 },
6666 {
6767 name : "Atlas with serverless" ,
6868 envVar : "ATLAS_SERVERLESS" ,
6969 certKeyFile : "" ,
70- wantErrCode : "" ,
70+ wantErr : "" ,
7171 },
7272 {
7373 name : "Atlas with srv file on replica set" ,
7474 envVar : "ATLAS_SRV_REPL" ,
7575 certKeyFile : "" ,
76- wantErrCode : "" ,
76+ wantErr : "" ,
7777 },
7878 {
7979 name : "Atlas with srv file on shared cluster" ,
8080 envVar : "ATLAS_SRV_SHRD" ,
8181 certKeyFile : "" ,
82- wantErrCode : "" ,
82+ wantErr : "" ,
8383 },
8484 {
8585 name : "Atlas with srv file on free tier" ,
8686 envVar : "ATLAS_SRV_FREE" ,
8787 certKeyFile : "" ,
88- wantErrCode : "" ,
88+ wantErr : "" ,
8989 },
9090 {
9191 name : "Atlas with srv file on TLS 1.1" ,
9292 envVar : "ATLAS_SRV_TLS11" ,
9393 certKeyFile : "" ,
94- wantErrCode : "" ,
94+ wantErr : "" ,
9595 },
9696 {
9797 name : "Atlas with srv file on TLS 1.2" ,
9898 envVar : "ATLAS_SRV_TLS12" ,
9999 certKeyFile : "" ,
100- wantErrCode : "" ,
100+ wantErr : "" ,
101101 },
102102 {
103103 name : "Atlas with srv file on serverless" ,
104104 envVar : "ATLAS_SRV_SERVERLESS" ,
105105 certKeyFile : "" ,
106- wantErrCode : "" ,
106+ wantErr : "" ,
107107 },
108108 {
109109 name : "Atlas with X509 Dev" ,
110110 envVar : "ATLAS_X509_DEV" ,
111111 certKeyFile : createAtlasX509DevCertKeyFile (t ),
112- wantErrCode : "" ,
112+ wantErr : "" ,
113113 },
114114 {
115115 name : "Atlas with X509 Dev no user" ,
116116 envVar : "ATLAS_X509_DEV" ,
117117 certKeyFile : createAtlasX509DevCertKeyFileNoUser (t ),
118- wantErrCode : "11" , // UserNotFound
118+ wantErr : " UserNotFound" ,
119119 },
120120 }
121121
@@ -135,13 +135,8 @@ func TestAtlas(t *testing.T) {
135135
136136 // Run basic connectivity test.
137137 err := runTest (context .Background (), clientOpts )
138- if tc .wantErrCode != "" {
139- var cmdErr * mongo.CommandError
140- if errors .As (err , & cmdErr ) {
141- assert .Equal (t , cmdErr .Code , tc .wantErrCode )
142- } else {
143- t .Fatalf ("expected error to be a command error, got: %v" , err )
144- }
138+ if tc .wantErr != "" {
139+ assert .ErrorContains (t , err , tc .wantErr , "expected error to contain %q" , tc .wantErr )
145140
146141 return
147142 }
0 commit comments