Skip to content

Commit

Permalink
wip: unit test InMemoryLogRecordExporter
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzurihaaa committed Jan 18, 2025
1 parent c71f1b7 commit 343bd07
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2021-2022 Workiva.
// Licensed under the Apache License, Version 2.0. Please see https://github.com/Workiva/opentelemetry-dart/blob/master/LICENSE for more information

@TestOn('vm')
import 'package:fixnum/fixnum.dart';
import 'package:opentelemetry/api.dart' as api;
import 'package:opentelemetry/sdk.dart' as sdk;
import 'package:opentelemetry/src/experimental_sdk.dart' as sdk;
import 'package:opentelemetry/src/sdk/logs/log_record_limit.dart';
import 'package:test/test.dart';

import '../../../mocks.dart';

void main() {
test('Test exporter', () async {
final exporter = sdk.InMemoryLogRecordExporter();
final logRecord = sdk.LogRecord(
instrumentationScope: sdk.InstrumentationScope('library_name', 'library_version', 'url://schema', []),
logRecordLimits: LogRecordLimitsImpl(),
timeProvider: FakeTimeProvider(now: Int64(123)),
resource: sdk.Resource([api.Attribute.fromString('resource.name', 'test')]),
)
..makeReadonly()
..body = 'Log Message';

await exporter.export([logRecord]);

expect(exporter.finishedLogRecords.length, 1);
expect(exporter.finishedLogRecords.first.instrumentationScope?.name, 'library_name');

await exporter.shutdown();

expect(exporter.finishedLogRecords.length, 0);
});
}

0 comments on commit 343bd07

Please sign in to comment.