diff options
author | Eliot Horowitz <eliot@10gen.com> | 2013-05-17 12:17:04 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2013-05-17 12:25:23 -0400 |
commit | 1990f56f85fd5a43bc35fffce028f5ef0d8ebd25 (patch) | |
tree | 1809b508f878189ff26d6e5605f0c13723a9dba4 /jstests/connection_string_validation.js | |
parent | 321e6eb0ed18154ea1b7ddbbfbd943189a007d4c (diff) | |
download | mongo-1990f56f85fd5a43bc35fffce028f5ef0d8ebd25.tar.gz |
make test work with any server port
Diffstat (limited to 'jstests/connection_string_validation.js')
-rw-r--r-- | jstests/connection_string_validation.js | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/jstests/connection_string_validation.js b/jstests/connection_string_validation.js index fe15ea6808c..4ecd1f926ee 100644 --- a/jstests/connection_string_validation.js +++ b/jstests/connection_string_validation.js @@ -1,9 +1,16 @@ // Test validation of connection strings passed to the JavaScript "connect()" function. // Related to SERVER-8030. +port = "27017" + +if ( db.getMongo().host.indexOf( ":" ) >= 0 ) { + var idx = db.getMongo().host.indexOf( ":" ); + port = db.getMongo().host.substring( idx + 1 ); +} + var goodStrings = [ - "localhost:27999/test", - "127.0.0.1:27999/test" + "localhost:" + port + "/test", + "127.0.0.1:" + port + "/test" ]; var badStrings = [ @@ -16,8 +23,8 @@ var badStrings = [ { s: "/", r: /^Missing host name/ }, { s: ":/", r: /^Missing host name/ }, { s: ":/test", r: /^Missing host name/ }, - { s: ":27999/", r: /^Missing host name/ }, - { s: ":27999/test", r: /^Missing host name/ }, + { s: ":" + port + "/", r: /^Missing host name/ }, + { s: ":" + port + "/test", r: /^Missing host name/ }, { s: "/test", r: /^Missing host name/ }, { s: "localhost:/test", r: /^Missing port number/ }, { s: "127.0.0.1:/test", r: /^Missing port number/ }, @@ -26,8 +33,8 @@ var badStrings = [ { s: "127.0.0.1:123456/test", r: /^Invalid port number/ }, { s: "127.0.0.1:65536/test", r: /^Invalid port number/ }, { s: "::1:65536/test", r: /^Invalid port number/ }, - { s: "127.0.0.1:27999/", r: /^Missing database name/ }, - { s: "::1:27999/", r: /^Missing database name/ } + { s: "127.0.0.1:" + port + "/", r: /^Missing database name/ }, + { s: "::1:" + port + "/", r: /^Missing database name/ } ]; function testGood(i, connectionString) { |