コード例 #1
0
ファイル: registryManager.test.js プロジェクト: Stono/Npmzor
 it('Should hit the second registry if the first returned a negative result', function(done) {
   var mockRegistry1 = deride.wrap(npmRegistry);    
   var mockRegistry2 = deride.wrap(npmRegistry);
   mockRegistry1.setup.getModuleIndex.toDoThis(function(name, tag, callback) {
     callback(undefined, null);
   });
   
   mockRegistry2.setup.getRoot.toReturn('registry2');
   mockRegistry2.setup.getModuleIndex.toDoThis(function(name, tag, callback) {
     callback(undefined, {
       _id: 'fake-repo'
     });
   });
   
   registryManager.addRegistrySync(mockRegistry1);
   registryManager.addRegistrySync(mockRegistry2);
   
   registryManager.getModuleIndex('fake-repo', function(err, details) {
     assert.equal(err, undefined, err);
     assert.equal(details._id, 'fake-repo');
     mockRegistry1.expect.getModuleIndex.called.once();
     mockRegistry2.expect.getModuleIndex.called.once();
     done();
   });
 });
コード例 #2
0
ファイル: registryManager.test.js プロジェクト: Stono/Npmzor
  beforeEach(function(done) {
    testUtil.clearAll();
    var httpUtil    = new HttpUtil(mockConfig);
    var db = new Db(mockConfig.db, {});
      
    internalRegistry = new InternalRegistry(mockConfig, db);

    mockCache   = deride.wrap(new RegistryCache(mockConfig, db));
    mockCache.setup.getIndex.toCallbackWith([undefined, null]);
    mockCache.setup.addIndex.toCallbackWith([undefined, null]);
     
    registryManager = new RegistryManager(mockConfig, mockCache, httpUtil, internalRegistry);
    done();
  });
コード例 #3
0
ファイル: registryManager.test.js プロジェクト: Stono/Npmzor
 beforeEach(function() {
   var httpUtil    = new HttpUtil(mockConfig);
   npmRegistry     = new NpmRegistry(mockConfig, httpUtil, registryRoot);
   
   var mockDb      = deride.stub(['collection']);
   var mockCache   = deride.wrap(new RegistryCache(mockConfig, mockDb));
   mockCache.setup.getIndex.toCallbackWith([undefined, null]);
   mockCache.setup.addIndex.toCallbackWith([undefined, null]);
   
   var mockInternal = deride.stub(['getModule', 'getModuleIndex']);
   mockInternal.setup.getModule.toCallbackWith([undefined, null]);
   mockInternal.setup.getModuleIndex.toCallbackWith([undefined, null]);
     
   registryManager = new RegistryManager(mockConfig, mockCache, httpUtil, mockInternal);    
 });
コード例 #4
0
ファイル: npmRegistry.test.js プロジェクト: Stono/Npmzor
  it('Should proxy package index requests to the external registry and return valid JSON', function(done) {
    var httpUtil   = deride.wrap(new HttpUtil(config));
    httpUtil.setup.getJsonUrl.toCallbackWith([
      undefined, 
      _.clone(sampleData, true)
    ]);

    var npmRegistry = new NpmRegistry(config, httpUtil, endpoint);
    npmRegistry.getModuleIndex('mkdirp', null, function(err, json) {
      assert.equal(err, undefined, err);
      assert.equal(json._id, 'mkdirp');
      httpUtil.expect.getJsonUrl.called.once('expectgetJsonUrl was not called the expected amount of times.');
      done();
    });
  });
コード例 #5
0
ファイル: registryManager.test.js プロジェクト: Stono/Npmzor
 it('Should forward requests to the external Registry', function(done) {
   var mockRegistry = deride.wrap(npmRegistry);
   mockRegistry.setup.getModuleIndex.toDoThis(function(name, tag, callback) {
     callback(undefined, {
       _id: 'fake-repo'
     });
   });
   
   registryManager.addRegistrySync(mockRegistry);    
   registryManager.getModuleIndex('fake-repo', function(err, details) {
     assert.equal(err, undefined, err);
     assert.equal(details._id, 'fake-repo');
     mockRegistry.expect.getModuleIndex.called.once();
     done();
   });
 });
コード例 #6
0
ファイル: npmRegistry.test.js プロジェクト: Stono/Npmzor
  it('Should return the path of a tgz package that has been downloaded', function(done) {
    var httpUtil   = deride.wrap(new HttpUtil(config));
    httpUtil.setup.getBinaryUrl.toCallbackWith([
      undefined, 
      'useless junk'
    ]);

    var npmRegistry = new NpmRegistry(config, httpUtil, endpoint);
    npmRegistry.getModule('simple-empty-app', 'simple-empty-app', '0.0.1', function(err, pathToTemp) {
      assert.equal(err, undefined, err);
      assert.notEqual(pathToTemp, undefined);
      assert.notEqual(pathToTemp, null);
      httpUtil.expect.getBinaryUrl.called.once('getBinaryUrl was not called the expected amount of times.');
      done();
    });
  });
コード例 #7
0
ファイル: npmRegistry.test.js プロジェクト: Stono/Npmzor
  it('Should rewrite result with address of this registry', function(done) {
    var httpUtil   = deride.wrap(new HttpUtil(config));
    httpUtil.setup.getJsonUrl.toCallbackWith([
      undefined, 
      _.clone(sampleData, true)
    ]);

    var npmRegistry = new NpmRegistry(config, httpUtil, endpoint);
    npmRegistry.getModuleIndex('mkdirp', null, function(err, json) {
      assert.equal(err, undefined, err);
      assert.notEqual(json, undefined);
      httpUtil.expect.getJsonUrl.called.once('getJsonUrl was caled more than once!');
      assert(JSON.stringify(json).indexOf('registry.npmjs.org') === -1, 'registry.npmjs.org was still found in the data');
      assert(JSON.stringify(json).indexOf(config.url) > -1, config.url + ' was not found in the data');
      assert.equal(json.versions['0.0.5'].dist.tarball, config.url + '/mkdirp/-/mkdirp-0.0.5.tgz');
      done();
    });

  });