Skip to content

Commit 911f867

Browse files
Merge branch 'master' of github.com:Workiva/w_module into AF-1540_consumer-specified-timing
2 parents fe4c6ef + 1b3c1a5 commit 911f867

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

lib/src/lifecycle_module.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,7 @@ abstract class LifecycleModule extends SimpleModule with Disposable {
10711071
rethrow;
10721072
} finally {
10731073
_activeSpan?.finish();
1074+
_activeSpan = null;
10741075
}
10751076
}
10761077
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: w_module
2-
version: 2.0.1
2+
version: 2.0.2
33
description: Base module classes with a well defined lifecycle for modular Dart applications.
44
authors:
55
- Workiva Client Platform Team <[email protected]>

test/lifecycle_module_test.dart

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ class TestLifecycleModule extends LifecycleModule {
100100
];
101101
}
102102

103+
// Overriding without re-applying the @protected annotation allows us to call
104+
// activeSpan in our tests below.
105+
@override
106+
Span get activeSpan => super.activeSpan;
107+
103108
// Overriding without re-applying the @protected annotation allows us to call
104109
// loadChildModule in our tests below.
105110
@override
@@ -484,6 +489,11 @@ void runTests(bool runSpanTests) {
484489
module.specifyFirstUsefulState();
485490
});
486491
});
492+
493+
test('activeSpan should be null when load is finished', () async {
494+
await module.load();
495+
expect(module.activeSpan, isNull);
496+
});
487497
}
488498

489499
group('with an onLoad that throws', () {
@@ -866,6 +876,7 @@ void runTests(bool runSpanTests) {
866876
['willResume', 'onResume', 'didResume']
867877
..addAll(expectedSuspendEvents));
868878
});
879+
869880
test('should emit lifecycle log events', () async {
870881
await gotoState(module, LifecycleState.loaded);
871882
expect(
@@ -892,6 +903,12 @@ void runTests(bool runSpanTests) {
892903
await module.suspend();
893904
});
894905

906+
test('activeSpan should be null when suspend is finished', () async {
907+
await gotoState(module, LifecycleState.loaded);
908+
await module.suspend();
909+
expect(module.activeSpan, isNull);
910+
});
911+
895912
test(
896913
'if a transition is in progress should wait to start this until that finishes',
897914
() async {
@@ -1170,6 +1187,12 @@ void runTests(bool runSpanTests) {
11701187
await module.resume();
11711188
});
11721189

1190+
test('activeSpan should be null when resume is finished', () async {
1191+
await gotoState(module, LifecycleState.suspended);
1192+
await module.resume();
1193+
expect(module.activeSpan, isNull);
1194+
});
1195+
11731196
test(
11741197
'if a transition is in progress should wait to start this until that finishes',
11751198
() async {
@@ -2135,6 +2158,11 @@ void runTests(bool runSpanTests) {
21352158
expect(span.parentContext.spanId, parentUnloadContext.spanId);
21362159
expect(span.tags['custom.unload.tag'], 'somevalue');
21372160
});
2161+
2162+
test('activeSpan should be null when unload is finished', () async {
2163+
await parentModule.unload();
2164+
expect(parentModule.activeSpan, isNull);
2165+
});
21382166
}
21392167

21402168
test('should emit lifecycle log events', () async {

0 commit comments

Comments
 (0)