@@ -9,5 +9,26 @@ function testConnection(testCase)
99 testCase .CONN_INFO .user ,...
1010 testCase .CONN_INFO .password ,' ' ,true ).isConnected);
1111 end
12+ function testConnectionExists(testCase )
13+ % testConnectionExists tests that will not fail if connection open
14+ % to the same host.
15+ % Fix https://github.com/datajoint/datajoint-matlab/issues/160
16+ st = dbstack ;
17+ disp([' ---------------' st(1 ).name ' ---------------' ]);
18+ dj .conn(testCase .CONN_INFO .host , ' ' , ' ' , ' ' , ' ' , true )
19+ dj .conn(testCase .CONN_INFO .host , ' ' , ' ' , ' ' , ' ' , true )
20+ end
21+ function testConnectionDiffHost(testCase )
22+ % testConnectionDiffHost tests that will fail if connection open
23+ % to a different host.
24+ % Fix https://github.com/datajoint/datajoint-matlab/issues/160
25+ st = dbstack ;
26+ disp([' ---------------' st(1 ).name ' ---------------' ]);
27+ dj .conn(testCase .CONN_INFO .host , ' ' , ' ' , ' ' , ' ' , true )
28+
29+ testCase .verifyError(@() dj .conn(...
30+ ' anything' , ' ' , ' ' , ' ' , ' ' , true ), ...
31+ ' DataJoint:Connection:AlreadyInstantiated' );
32+ end
1233 end
1334end
0 commit comments