diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2017-09-20 11:50:02 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2017-09-20 11:50:02 -0400 |
commit | 2b44ac6faf81d217a7418f0a55cc6b7f463e9dbe (patch) | |
tree | 46ffda6258b7073d722a8dfae1088dacdf897d3a /jstests/core/autocomplete.js | |
parent | 8c4170f40f189050b87129a9076149cdc0f47234 (diff) | |
download | mongo-2b44ac6faf81d217a7418f0a55cc6b7f463e9dbe.tar.gz |
SERVER-30769 Mongo shell throws 'exception during autocomplete'
Diffstat (limited to 'jstests/core/autocomplete.js')
-rw-r--r-- | jstests/core/autocomplete.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/jstests/core/autocomplete.js b/jstests/core/autocomplete.js new file mode 100644 index 00000000000..6eb6e21a7a3 --- /dev/null +++ b/jstests/core/autocomplete.js @@ -0,0 +1,42 @@ +/** + * Validate auto complete works for various javascript types implemented by C++. + */ +(function() { + 'use strict'; + + function testAutoComplete(prefix) { + // This method updates a global object with an array of strings on success. + shellAutocomplete(prefix); + return __autocomplete__; + } + + // Create a collection + db.auto_complete_coll.insert({}); + + // Validate DB auto completion + const db_stuff = testAutoComplete('db.'); + + // Verify we enumerate built-in methods + assert.contains('db.prototype', db_stuff); + assert.contains('db.hasOwnProperty', db_stuff); + assert.contains('db.toString(', db_stuff); + + // Verify we have some methods we added + assert.contains('db.adminCommand(', db_stuff); + assert.contains('db.runCommand(', db_stuff); + + // Verify we enumerate collections + assert.contains('db.auto_complete_coll', db_stuff); + + // Validate Collection autocompletion + const coll_stuff = testAutoComplete('db.auto_complete_coll.'); + + // Verify we enumerate built-in methods + assert.contains('db.auto_complete_coll.prototype', coll_stuff); + assert.contains('db.auto_complete_coll.hasOwnProperty', coll_stuff); + assert.contains('db.auto_complete_coll.toString(', coll_stuff); + + // Verify we have some methods we added + assert.contains('db.auto_complete_coll.aggregate(', coll_stuff); + assert.contains('db.auto_complete_coll.runCommand(', coll_stuff); +})();
\ No newline at end of file |