UNPKG

ca-apm-probe

Version:

CA APM Node.js Agent monitors real-time health and performance of Node.js applications

53 lines (43 loc) 1.94 kB
/** * Copyright (c) 2015 CA. All rights reserved. * * This software and all information contained therein is confidential and proprietary and * shall not be duplicated, used, disclosed or disseminated in any way except as authorized * by the applicable license agreement, without the express written permission of CA. All * authorized reproductions must be marked with this language. * * EXCEPT AS SET FORTH IN THE APPLICABLE LICENSE AGREEMENT, TO THE EXTENT * PERMITTED BY APPLICABLE LAW, CA PROVIDES THIS SOFTWARE WITHOUT WARRANTY * OF ANY KIND, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL CA BE * LIABLE TO THE END USER OR ANY THIRD PARTY FOR ANY LOSS OR DAMAGE, DIRECT OR * INDIRECT, FROM THE USE OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, LOST * PROFITS, BUSINESS INTERRUPTION, GOODWILL, OR LOST DATA, EVEN IF CA IS * EXPRESSLY ADVISED OF SUCH LOSS OR DAMAGE. */ 'use strict'; var guidgenerator = require('../lib/utils/guidgenerator'); var assert = require('assert'); describe('GuidGenerator', function() { describe('.generateGuid()', function() { it('should return valid guid', function() { assert.notEqual(guidgenerator.generateGuid(), null, "guid is null"); assert.notEqual(guidgenerator.generateGuid(), undefined, "guid is undefined"); }); it('guid should be of type string', function() { assert.strictEqual(typeof guidgenerator.generateGuid(), 'string', "type of guid is not string"); }); it('guid should be unique', function() { var map = {}; // create 1000 guids for(var i = 0; i < 1000; i++){ map[guidgenerator.generateGuid()] = true; } var customGuid = '1234ABCD'; map[customGuid] = true; // test if we have correct map implementaion assert.strictEqual(customGuid in map, true); assert.notEqual(guidgenerator.generateGuid() in map, true); }); }); })