Example #1
0
	exports.findInNpmRegistry('test', function (error, result) {
		testing.check(error, callback);
		testing.check(result, callback);
		//restore requestLib.get
		requestLib.get = restoreRequestLibGet;
		testing.success(callback);
	});
Example #2
0
	const server = exports.startServer(options, error => {
		testing.check(error, 'Could not start server', callback);
		server.close(error => {
			testing.check(error, 'Could not stop server', callback);
			testing.success(callback);
		});
	});
Example #3
0
		exports.findPending(name, function(error, result)
		{
			testing.check(error, 'Could not find package', callback);
			testing.assert(result, 'Did not find package', callback);
			testing.assertEquals(result.value, value, 'Invalid value', callback);
			testing.success(callback);
		});
Example #4
0
 pending(pendingObject, function (error, result) {
     testing.check(error, callback);
     testing.assert(Math.abs(result.repoTotalIssues[0] - 2/3) < 0.00001, 'repoTotalIssues should be 2/3 for this repo', callback);
     testing.assertEquals(result.repoOpenIssues[0], 1, 'repoOpenIssues should be 1 for this repo', callback);
     testing.assertEquals(result.repoLongOpenIssues[0], 1, 'repoLongOpenIssues should be 1 for this repo', callback);
     testing.success(callback);
 });
Example #5
0
	exports.findInNpmRegistry('test', function (error, result) {
		testing.check(result, callback);
		testing.assert(error, 'no error returned when request returned invalid json', callback);
		//restore requestLib.get
		requestLib.get = restoreRequestLibGet;
		testing.success(callback);
	});
Example #6
0
 exports.estimate(entry, function (error, result) {
     testing.check(error, callback);
     testing.assertEquals(result.repoTotalIssues[0], 0, 'repoTotalIssues should be zero for a invalid repo', callback);
     testing.assertEquals(result.repoOpenIssues[0], 0, 'repoOpenIssues should be zero for a invalid repo', callback);
     testing.assertEquals(result.repoLongOpenIssues[0], 0, 'repoLongOpenIssues should be zero for a invalid repo', callback);
     testing.success(callback);
 });
Example #7
0
 exports.estimate(entry, function (error, result) {
     testing.check(error, callback);
     testing.assert(result.check, 'estimate should return the right result when pending returns a result', callback);
     //restore pending
     pending = restorePending;
     testing.success(callback);
 });
Example #8
0
 getIssuesForPageLastYear('repoOwner', 'repoName', 2, function (error, result) {
     testing.check(result, callback);
     testing.assertEquals(error, config.githubApiMaxCallsReachedError, 'no error returned by getIssuesForPageLastYear when no more github API calls are available', callback);
     // restore request
     request = restoreRequest;
     testing.success(callback);
 });
Example #9
0
 getIssuesForPageLastYear('repoOwner', 'repoName', 2, function (error, result) {
     testing.check(result, callback);
     testing.assert(error, 'no error returned by getIssuesForPageLastYear when the request returns an error', callback);
     // restore request
     request = restoreRequest;
     testing.success(callback);
 });
Example #10
0
 getIssuesForPageLastYear('repoOwner', 'repoName', 2, function (error, result) {
     testing.check(error, callback);
     testing.assertEquals(result.issues.length, 0, 'not found should return empty issues', callback);
     // restore request
     request = restoreRequest;
     testing.success(callback);
 });
Example #11
0
	const latency = new Latency(options, (error, result) => {
		testing.check(error, 'Could not compute latency', callback);
		testing.assertEquals(result.totalRequests, 10, 'Invalid total requests', callback);
		testing.assertEquals(result.totalErrors, 1, 'Invalid total errors', callback);
		testing.assert(errorCode in result.errorCodes, 'Error code not found', callback);
		testing.assertEquals(result.errorCodes[errorCode], 1, 'Should have one ' + errorCode, callback);
		testing.success(callback);
	});
Example #12
0
			server1.close(function(error) {
				testing.check(error, 'Could not stop server 1', callback);
				// y el segundo
				server2.close(function(error) {
					testing.check(error, 'Could not stop server 2', callback);
					testing.success(callback);
				});
			});
Example #13
0
 exports.estimate(entry, function (error, result) {
     testing.check(error, callback);
     testing.assertEquals(result.repoTotalIssues[0], 0, 'repoTotalIssues should be zero for this repo', callback);
     testing.assert(Math.abs(result.repoOpenIssues[0] - 0.2) < 0.00001, 'repoOpenIssues should be 0.2 for this repo', callback);
     testing.assertEquals(result.repoLongOpenIssues[0], 1, 'repoLongOpenIssues should be 1 for this repo', callback);
     pending = restorePending;
     testing.success(callback);
 });
Example #14
0
 getIssuesForPageLastYear('repoOwner', 'repoName', 2, function (error, result) {
     testing.check(error, callback);
     testing.assertEquals(result.githubIssuesLastPage, 12, 'wrong last page of issues returned', callback);
     testing.assertEquals(result.issues.length, 2, 'wrong number of issues returned', callback);
     // restore request
     request = restoreRequest;
     testing.success(callback);
 });
Example #15
0
	exports.retrieveShield('test', 65, '', function(error, result)
	{
		testing.check(error, 'Could not retrieve shield', callback);
		testing.assertEquals(result, shieldsResponse, 'Did not retrieve shields correctly', callback);
		// restore basicRequest
		basicRequest = restoreBasicRequest;
		testing.success(callback);
	});
Example #16
0
	exports.findInNpmRegistry('test', function (error, result) {
		testing.check(error, callback);
		testing.assertEquals(result.name, 'testName', 'wrong name in response for valid request', callback);
		testing.assertEquals(result.repository, 'testRepository', 'wrong repository in response for valid request', callback);
		testing.assertEquals(result.description, 'testDescription', 'wrong description in response for valid request', callback);
		//restore requestLib.get
		requestLib.get = restoreRequestLibGet;
		testing.success(callback);
	});
Example #17
0
	var server = exports.startServer(options, function(error)
	{
		testing.check(error, 'Could not start server', callback);
		server.close(function(error)
		{
			testing.check(error, 'Could not stop server', callback);
			testing.success(callback);
		});
	});
Example #18
0
			exports.removePending(name, function(error)
			{
				testing.check(error, 'Could not remove package', callback);
				exports.findPending(name, function(error, result)
				{
					testing.check(error, 'Could not find package again', callback);
					testing.assert(!result, 'Should not find package', callback);
					testing.success(callback);
				});
			});
Example #19
0
	const latency = new Latency(options, error => {
		testing.check(error, 'Error while testing latency percentiles', callback);
		const percentiles = latency.getResults().percentiles;

		Object.keys(percentiles).forEach(percentile => {
			testing.assert(percentiles[percentile] !== false, 'Empty percentile for %s', percentile, callback);
		});

		testing.success(percentiles, callback);
	});
Example #20
0
	var latency = new exports.Latency(options, function(error)
	{
		testing.check(error, 'Error while testing latency percentiles', callback);
		var percentiles = latency.getResults().percentiles;

		Object.keys(percentiles).forEach(function(percentile) {
			testing.assert(percentiles[percentile] !== false, 'Empty percentile for %s', percentile, callback);
		});

		testing.success(percentiles, callback);
	});
Example #21
0
	db.reconnect(function(error)
	{
		testing.check(error, 'Could not set test mode', callback);
		// init
		openCollection(function(error, collection)
		{
			testing.check(error, 'Could not open collection', callback);
			testing.assert(collection, 'Did not open collection', callback);
			testing.success(callback);
		});
	});
Example #22
0
	exports.update(object, function(error)
	{
		testing.check(error, 'Could not save object', callback);
		exports.find(name, function(error, result)
		{
			testing.check(error, 'Could not find package', callback);
			testing.assert(result, 'Did not find package', callback);
			testing.assertEquals(result.value, value, 'Invalid value', callback);
			testing.success(callback);
		});
	});
Example #23
0
	request.post('https://httpbin.org/post', json, function(error, result)
	{
		testing.check(error, 'Should post to httpbin', callback);
		testing.assert(result, 'Should have returned something', callback);
		request.post('https://s3.amazonaws.com/', {nothing: true}, function(error, result)
		{
			testing.assert(error, 'Should not post to S3', callback);
			testing.assert(result, 'Should have got a result from S3', callback);
			testing.assert(result.statusCode >= 400, 'Should have got a 4xx from S3', callback);
			testing.success(callback);
		});
	});
Example #24
0
		var server2 = start(1708, function(error) {
			// comprueba el error! usa diferentes mensajes para cada error
			testing.check(error, 'Could not start server 2', callback);
			// ahora cierra el primer servidor
			server1.close(function(error) {
				testing.check(error, 'Could not stop server 1', callback);
				// y el segundo
				server2.close(function(error) {
					testing.check(error, 'Could not stop server 2', callback);
					testing.success(callback);
				});
			});
		});
Example #25
0
	request.get('http://httpbin.org/', function(error, result)
	{
		testing.check(error, 'Could not access httpbin', callback);
		testing.assert(result.contains('httpbin'), 'Invalid contents for httpbin page', callback);
		request.get('http://httpbin.org/fake_page', function(error)
		{
			testing.assert(error, 'Could access fake page', callback);
			request.get('http://askdjfsjljwer.soiueiruouoisfoisdo.reuioweiwr/', function(error)
			{
				testing.assert(error, 'Could access fake domain', callback);
				testing.success(callback);
			});
		});
	});
Example #26
0
 var socket = net.connect(port, 'localhost', function(error) {
     testing.check(error, 'Could not connect', callback);
     socket.on('data', function(data) {
         var message = String(data).trim();
         if (message == 'Hello?')
         {
             socket.write('hello');
             return;
         }
         testing.assertEquals(message, 'world', 'Bad response', callback);
         server.close(function(error) {
             testing.check(error, 'Could not stop server', callback);
             testing.success(callback);
         });
     });
 });
Example #27
0
	exports.update(object, function(error)
	{
		testing.check(error, 'Could not save object', callback);
		exports.find(name, function(error, result)
		{
			testing.check(error, 'Could not find package', callback);
			testing.assert(result, 'Did not find package', callback);
			exports.remove(name, function(error)
			{
				testing.check(error, 'Could not remove package', callback);
				exports.find(name, function(error, result)
				{
					testing.check(error, 'Could not find package again', callback);
					testing.assert(!result, 'Should not find package', callback);
					testing.success(callback);
				});
			});
		});
	});
Example #28
0
		var socket = net.connect(port, 'localhost', function(error) {
			testing.check(error, 'Could not connect', callback);
			socket.on('data', function(data) {
				var message = String(data).trim();
				if (message == 'Hello?')
				{
					socket.write('Not hello!');
					return;
				}
				// debe recibir ERROR
				testing.assertEquals(message, 'ERROR', 'Invalid response', callback);
				// ahora tenemos que cerrar el socket, no se cierra solo
				socket.end(function() {
					// y ahora el servidor como antes
					server.close(function(error) {
						testing.check(error, 'Could not stop server', callback);
						testing.success(callback);
					});
				});
			});
		});
Example #29
0
 server.close(function(error) {
     testing.check(error, 'Could not stop server', callback);
     testing.success(callback);
 });
Example #30
0
		openCollection(function(error, collection)
		{
			testing.check(error, 'Could not open collection', callback);
			testing.assert(collection, 'Did not open collection', callback);
			testing.success(callback);
		});