-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: share duplicate mocks across testsuite
(only for the generic mocks, with 0 implementation detail leakage)
- Loading branch information
1 parent
0369740
commit ecc9b0b
Showing
12 changed files
with
128 additions
and
72 deletions.
There are no files selected for viewing
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
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
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
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
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,41 @@ | ||
import 'package:at_client/at_client.dart'; | ||
import 'package:mocktail/mocktail.dart'; | ||
import 'package:noports_core/src/common/io_types.dart'; | ||
import 'package:noports_core/sshnp_foundation.dart'; | ||
import 'package:socket_connector/socket_connector.dart'; | ||
|
||
/// A [void Function()] stub | ||
abstract class FunctionCaller { | ||
void call(); | ||
} | ||
|
||
class FunctionStub extends Mock implements FunctionCaller {} | ||
|
||
/// The basic mocks that are repeated countless times throughout the test suite | ||
class MockAtClient extends Mock implements AtClient {} | ||
|
||
class MockSshnpParams extends Mock implements SshnpParams {} | ||
|
||
class MockSshnpdChannel extends Mock implements SshnpdChannel {} | ||
|
||
class MockSshrvdChannel extends Mock implements SshrvdChannel {} | ||
|
||
/// [dart:io] Mocks | ||
class MockProcess extends Mock implements Process {} | ||
|
||
class MockSocketConnector extends Mock implements SocketConnector {} | ||
|
||
|
||
/// Stubbing for [Process.start] | ||
abstract class StartProcessCaller { | ||
Future<Process> call( | ||
String executable, | ||
List<String> arguments, { | ||
bool runInShell, | ||
ProcessStartMode mode, | ||
}); | ||
} | ||
|
||
class StartProcessStub extends Mock implements StartProcessCaller {} | ||
|
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
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
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
20 changes: 20 additions & 0 deletions
20
packages/noports_core/test/sshnp/util/sshrvd_channel/sshrvd_channel_mocks.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,20 @@ | ||
import 'package:mocktail/mocktail.dart'; | ||
import 'package:noports_core/sshnp_foundation.dart'; | ||
import 'package:noports_core/sshrv.dart'; | ||
|
||
/// Stubbing for [SshrvGenerator] typedef | ||
abstract class SshrvGeneratorCaller<T> { | ||
Sshrv<T> call(String host, int port, {int localSshdPort}); | ||
} | ||
|
||
class SshrvGeneratorStub extends Mock implements SshrvGeneratorCaller {} | ||
|
||
/// Stubbed [SshrvdChannel] which we are testing | ||
class StubbedSshrvdChannel<T> extends SshrvdChannel<T> { | ||
StubbedSshrvdChannel({ | ||
required super.atClient, | ||
required super.params, | ||
required super.sessionId, | ||
required super.sshrvGenerator, | ||
}); | ||
} |
31 changes: 31 additions & 0 deletions
31
packages/noports_core/test/sshnp/util/sshrvd_channel/sshrvd_channel_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,31 @@ | ||
import 'package:test/test.dart'; | ||
import 'package:uuid/uuid.dart'; | ||
|
||
import '../../sshnp_mocks.dart'; | ||
import 'sshrvd_channel_mocks.dart'; | ||
|
||
void main() { | ||
group('SshrvdChannel', () { | ||
late SshrvGeneratorStub sshrvGeneratorStub; | ||
late MockAtClient mockAtClient; | ||
late MockSshnpParams mockParams; | ||
late String sessionId; | ||
late StubbedSshrvdChannel stubbedSshrvdChannel; | ||
|
||
setUp(() { | ||
sshrvGeneratorStub = SshrvGeneratorStub(); | ||
mockAtClient = MockAtClient(); | ||
mockParams = MockSshnpParams(); | ||
sessionId = Uuid().v4(); | ||
|
||
stubbedSshrvdChannel = StubbedSshrvdChannel( | ||
atClient: mockAtClient, | ||
params: mockParams, | ||
sessionId: sessionId, | ||
sshrvGenerator: sshrvGeneratorStub, | ||
); | ||
}); | ||
|
||
|
||
}); // group SshrvdChannel | ||
} |
1 change: 1 addition & 0 deletions
1
packages/noports_core/test/sshnp/util/sshrvd_channel/sshrvd_dart_channel_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 @@ | ||
void main() {} |
1 change: 1 addition & 0 deletions
1
packages/noports_core/test/sshnp/util/sshrvd_channel/ssrhvd_exec_channel_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 @@ | ||
void main() {} |