-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51762f2
commit d20195c
Showing
2 changed files
with
40 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import 'package:fixnum/fixnum.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:mockito/mockito.dart'; | ||
import 'package:viam_sdk/protos/service/discovery.dart'; | ||
import 'package:viam_sdk/src/gen/common/v1/common.pb.dart'; | ||
import 'package:viam_sdk/src/gen/service/discovery/v1/discovery.pbgrpc.dart'; | ||
import 'package:viam_sdk/viam_sdk.dart'; | ||
|
||
import '../mocks/mock_response_future.dart'; | ||
import '../mocks/service_clients_mocks.mocks.dart'; | ||
|
||
class FakeDiscoveryClient extends DiscoverClient { | ||
@override | ||
DiscoveryServiceClient get client => _client; | ||
|
||
final MockDiscoveryServiceClient _client; | ||
|
||
FakeDiscoveryClient(super.name, super.channel, this._client); | ||
} | ||
|
||
void main() { | ||
late DiscoveryClient client; | ||
late MockDiscoveryServiceClient serviceClient; | ||
|
||
setUp(() { | ||
serviceClient = MockDiscoveryServiceClient(); | ||
client = FakeDiscoveryClient('discovery', MockClientChannelBase(), serviceClient); | ||
}); | ||
|
||
group('Discovery RPC Client Tests', () { | ||
test('discoverResources', () async { | ||
final expected = [ComponentConfig()]; | ||
when(serviceClient.discoverResources(any)) | ||
.thenAnswer((_) => MockResponseFuture.value(DiscoverResourcesResponse(discovery: expected))); | ||
final response = await client.discoverResources('discoveryName'); | ||
expect(response, equals(expected)); | ||
}); | ||
}); | ||
} |