Example #1
0
  it ("completes successfully when there are now errors", function(done){
    sinon.stub(index, 'getOptions', function(cb){
      return cb(null, {}); 
    });
    sinon.stub(index, 'sendToCoveralls', function(postData, cb){
      cb(null, {statusCode : 200}, "body");
      done();
    });
		var path = __dirname + "/../fixtures/onefile.lcov";
    var input = fs.readFileSync(path, "utf8");
		index.handleInput(input);
  });
Example #2
0
 it ("returns an error when there's a bad status code", function(done){
   sinon.stub(index, 'getOptions', function(cb){
     return cb(null, {}); 
   });
   sinon.stub(index, 'sendToCoveralls', function(postData, cb){
     cb(null, {statusCode : 500}, "body");
   });
   var path = __dirname + "/../fixtures/onefile.lcov";
   var input = fs.readFileSync(path, "utf8");
   index.handleInput(input, function(err){
     err.should.equal("Bad response: 500 body");
     done();
   });
 });
Example #3
0
 it ("returns an error when there's an error sending", function(done){
   sinon.stub(index, 'getOptions', function(cb){
     return cb(null, {}); 
   });
   sinon.stub(index, 'sendToCoveralls', function(postData, cb){
     cb("some error");
   });
   var path = __dirname + "/../fixtures/onefile.lcov";
   var input = fs.readFileSync(path, "utf8");
   index.handleInput(input, function(err){
     err.should.equal("some error");
     done();
   });
 });
Example #4
0
  it ("throws an error when there's a bad status code", function(done){
    sinon.stub(index, 'getOptions', function(cb){
      return cb(null, {}); 
    });
    sinon.stub(index, 'sendToCoveralls', function(postData, cb){
      try {
        cb(null, {statusCode : 500}, "body");
        should.fail("expected exception was not raised");
      } catch (ex) {
        done();
      }
    });
		var path = __dirname + "/../fixtures/onefile.lcov";
    var input = fs.readFileSync(path, "utf8");
		index.handleInput(input);
  });
Example #5
0
 it ("returns an error when there's an error getting options", function(done){
   sinon.stub(index, 'getOptions', function(cb){
     return cb("some error", {}); 
   });
   var path = __dirname + "/../fixtures/onefile.lcov";
   var input = fs.readFileSync(path, "utf8");
   index.handleInput(input, function(err){
     err.should.equal("some error");
     done();
   });
 });
Example #6
0
  it ("passes on the correct params to request.post", function(done){
    sinon.stub(request, 'post', function(obj, cb){
      obj.url.should.equal('https://coveralls.io/api/v1/jobs');
      obj.form.should.eql({json : '{"some":"obj"}'});
      cb('err', 'response', 'body');
    });

    var obj = {"some":"obj"};
	index.sendToCoveralls(obj, function(err, response, body){
      err.should.equal('err');
      response.should.equal('response');
      body.should.equal('body');
      done();
    });
  });
Example #7
0
  it ("allows sending to enterprise url", function(done){
    process.env.COVERALLS_ENDPOINT = 'https://coveralls-ubuntu.domain.com';
    sinon.stub(request, 'post', function(obj, cb){
      obj.url.should.equal('https://coveralls-ubuntu.domain.com/api/v1/jobs');
      obj.form.should.eql({json : '{"some":"obj"}'});
      cb('err', 'response', 'body');
    });

    var obj = {"some":"obj"};
	index.sendToCoveralls(obj, function(err, response, body){
      err.should.equal('err');
      response.should.equal('response');
      body.should.equal('body');
      done();
    });
  });