Skip to content

Commit

Permalink
Adds one more test case
Browse files Browse the repository at this point in the history
What happens if we start watching for the addr file but
it never shows up?

The answer is: our outer timeout catches us.
So the stream would emit 'AgentState.unreachable'
and we are done.
  • Loading branch information
CarlosNihelton committed Oct 23, 2023
1 parent e6ace0b commit b4dc200
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions gui/packages/ubuntupro/test/startup/agent_monitor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,32 @@ void main() {
verify(mockClient.ping()).called(1);
});

test('timeout if never addr', () async {
final mockClient = MockAgentApiClient();
// Fakes a successful ping.
when(mockClient.ping()).thenAnswer((_) async => true);
final monitor = AgentStartupMonitor(
/// A launch request will always succeed, but never writes the addr file.
agentLauncher: () async {
return true;
},
clientFactory: (port) => mockClient,
appName: kAppName,
addrFileName: kAddrFileName,
onClient: (_) {},
);

await expectLater(
monitor.start(interval: kInterval),
emitsInOrder([
AgentState.querying,
// instead of waiting the addr file to show up forever, we are caught by our internal timeout.
AgentState.unreachable,
]),
);
verifyNever(mockClient.ping());
});

test('await async onClient callback', () async {
final completeMe = Completer<void>();
final mockClient = MockAgentApiClient();
Expand Down

0 comments on commit b4dc200

Please sign in to comment.