-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: unit test InMemoryLogRecordExporter
- Loading branch information
1 parent
c71f1b7
commit 343bd07
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
test/unit/sdk/logs/exporters/inmemory_log_record_exporter_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |