Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-1986

Clean up collection_tests and make them DRY

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • next
    • Affects Version/s: None
    • Component/s: None
    • None

      collection_tests has a lot of duplication that we can reduce. Most of the tests follow this pattern:

      var self = this;
      var client = self.configuration.newClient();
      client.connect(function(err, client) {
        var db = client.db(self.configuration.db);
      
        db.createCollection('test_collection_methods', function(err, collection) {
           test.equal('test_collection_methods', collection.collectionName);
      
           // some operation
        });
      });
      

      We can move this common behavior into beforeEach to reduce duplication across tests that follow this pattern. While doing that, we can also replace var with const or let as needed, eliminate the use of self, and switch to arrow functions.

            Assignee:
            rosemary.yin@mongodb.com Rosemary Yin (Inactive)
            Reporter:
            katherine.walker@mongodb.com Katherine Walker (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: