Added comprehensive test suite and documentation for gRPC integration: - test/api/grpc_config_test.dart: Unit tests for GrpcConfig - test/api/grpc_client_test.dart: Unit tests for GrpcCqrsApiClient - test/api/api_mode_config_test.dart: Unit tests for ApiModeConfig - test/e2e/GRPC_E2E_VERIFICATION.md: Manual E2E testing guide All 18 tests pass. Flutter analyze shows no issues. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
57 lines
1.9 KiB
Dart
57 lines
1.9 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:planb_logistic/api/grpc_config.dart';
|
|
|
|
void main() {
|
|
group('GrpcConfig', () {
|
|
test('development config has correct values', () {
|
|
const config = GrpcConfig.development;
|
|
|
|
expect(config.host, equals('192.168.88.228'));
|
|
expect(config.port, equals(5011));
|
|
expect(config.useTls, isFalse);
|
|
expect(config.allowSelfSignedCertificate, isTrue);
|
|
expect(config.timeout, equals(const Duration(seconds: 30)));
|
|
expect(config.address, equals('192.168.88.228:5011'));
|
|
});
|
|
|
|
test('production config has correct values', () {
|
|
const config = GrpcConfig.production;
|
|
|
|
expect(config.host, equals('grpc-route.goutezplanb.com'));
|
|
expect(config.port, equals(443));
|
|
expect(config.useTls, isTrue);
|
|
expect(config.allowSelfSignedCertificate, isFalse);
|
|
expect(config.timeout, equals(const Duration(seconds: 30)));
|
|
expect(config.address, equals('grpc-route.goutezplanb.com:443'));
|
|
});
|
|
|
|
test('custom config can be created', () {
|
|
const config = GrpcConfig(
|
|
host: 'custom.example.com',
|
|
port: 9000,
|
|
timeout: Duration(seconds: 60),
|
|
useTls: true,
|
|
allowSelfSignedCertificate: true,
|
|
);
|
|
|
|
expect(config.host, equals('custom.example.com'));
|
|
expect(config.port, equals(9000));
|
|
expect(config.useTls, isTrue);
|
|
expect(config.allowSelfSignedCertificate, isTrue);
|
|
expect(config.timeout, equals(const Duration(seconds: 60)));
|
|
expect(config.address, equals('custom.example.com:9000'));
|
|
});
|
|
|
|
test('default values are correctly applied', () {
|
|
const config = GrpcConfig(
|
|
host: 'test.example.com',
|
|
port: 443,
|
|
);
|
|
|
|
expect(config.useTls, isTrue);
|
|
expect(config.allowSelfSignedCertificate, isFalse);
|
|
expect(config.timeout, equals(const Duration(seconds: 30)));
|
|
});
|
|
});
|
|
}
|