-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: SshnpdChannel #587
test: SshnpdChannel #587
Conversation
@@ -10,7 +10,7 @@ mixin class AsyncInitialization { | |||
// * Public members | |||
|
|||
/// Used to check if initialization has started | |||
bool get initalizeStarted => _initializeStarted; | |||
bool get initializeStarted => _initializeStarted; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed a typo
} | ||
|
||
/// Main reponse handler for the daemon's notifications. | ||
Future<void> _handleSshnpdResponses(AtNotification notification) async { | ||
@visibleForTesting | ||
Future<void> handleSshnpdResponses(AtNotification notification) async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scope: Private -> Visible for Testing
@@ -234,7 +235,8 @@ abstract class SshnpdChannel with AsyncInitialization, AtClientBindings { | |||
} | |||
|
|||
/// A custom implementation of AtClient.getAtKeys which bypasses the cache | |||
Future<List<AtKey>> _getAtKeysRemote( | |||
@visibleForTesting | |||
Future<List<AtKey>> getAtKeysRemote( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scope: Private -> Visible for Testing
@@ -17,7 +17,7 @@ void main() { | |||
late SshrvGeneratorStub<String> sshrvGeneratorStub; | |||
late MockAtClient mockAtClient; | |||
late StreamController<AtNotification> notificationStreamController; | |||
late FunctionStub notifyStub; | |||
late NotifyStub notifyStub; | |||
late SubscribeStub subscribeStub; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't verifying the arguments passed into notify, so I created a NotifyStub class which allows me to validate those arguments
}, | ||
subscribe: ({regex, shouldDecrypt = false}) { | ||
return subscribeStub(); | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removed function is now in a when(notificationInvocation).thenAnswer(...)
block later on
), | ||
), | ||
any(), | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the better argument matching as mentioned, checking that the values contained in the key passed in are as expected
|
||
expect(stubbedSshrvdChannel.host, '234.234.234.234'); | ||
expect(stubbedSshrvdChannel.port, 135); | ||
}); // test Initialization - non-sshrvd host | ||
|
||
test('Initialization completes - sshrvd host', () async { | ||
/// Set the required parameters | ||
whenInitializationWithSshrvdHost(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an init completion test, which checks if completeInitialization()
is called when callInitialization()
is called ... this only needs to be tested in certain places, usually impl classes, but initialization only occurs in the base class for sshrvd channel, so we can call and test for it in the base class.
- What I did
- How I did it
- How to verify it
- Description for the changelog
test: SshnpdChannel