Skip to content

Commit

Permalink
chore: expand id generation testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan committed Mar 3, 2020
1 parent fdd993f commit f539c99
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions packages/opentelemetry-core/test/platform/id.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,31 @@ import * as assert from 'assert';
import { randomSpanId, randomTraceId } from '../../src/platform';

describe('randomTraceId', () => {
it('returns different 32-char hex strings', () => {
it('returns 32 character hex strings', () => {
const traceId = randomTraceId();
assert.ok(traceId.match(/[a-f0-9]{32}/));
assert.ok(!traceId.match(/^0+$/))
});

it('returns different ids on each call', () => {
const traceId1 = randomTraceId();
const traceId2 = randomTraceId();

assert.notDeepStrictEqual(traceId1, traceId2);
});
});

describe('randomSpanId', () => {
it('returns different 16-char hex string', () => {
it('returns 16 character hex strings', () => {
const spanId = randomSpanId();
assert.ok(spanId.match(/[a-f0-9]{16}/));
assert.ok(!spanId.match(/^0+$/))
})

it('returns different ids on each call', () => {
const spanId1 = randomSpanId();
const spanId2 = randomSpanId();

assert.notDeepStrictEqual(spanId1, spanId2);
});
});

0 comments on commit f539c99

Please sign in to comment.