mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-09-20 04:54:55 -04:00
integration test and config work
This commit is contained in:
parent
8818e63dc0
commit
a04d4e12c5
17 changed files with 521 additions and 304 deletions
40
veilid-flutter/example/integration_test/app_test.dart
Normal file
40
veilid-flutter/example/integration_test/app_test.dart
Normal file
|
@ -0,0 +1,40 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
|
||||
import 'fixtures.dart';
|
||||
import 'test_veilid_config.dart';
|
||||
|
||||
void main() {
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
group('VeilidConfig', () {
|
||||
final fixture = DefaultFixture();
|
||||
setUp(fixture.setUp);
|
||||
tearDown(fixture.tearDown);
|
||||
|
||||
test('test VeilidConfig defaults', testVeilidConfigDefaults);
|
||||
});
|
||||
|
||||
// group('end-to-end test', () {
|
||||
// testWidgets('tap on the floating action button, verify counter',
|
||||
// (tester) async {
|
||||
// // Load app widget.
|
||||
// await tester.pumpWidget(const MyApp());
|
||||
|
||||
// // Verify the counter starts at 0.
|
||||
// expect(find.text('0'), findsOneWidget);
|
||||
|
||||
// // Finds the floating action button to tap on.
|
||||
// final fab = find.byKey(const Key('increment'));
|
||||
|
||||
// // Emulate a tap on the floating action button.
|
||||
// await tester.tap(fab);
|
||||
|
||||
// // Trigger a frame.
|
||||
// await tester.pumpAndSettle();
|
||||
|
||||
// // Verify the counter increments by 1.
|
||||
// expect(find.text('1'), findsOneWidget);
|
||||
// });
|
||||
// });
|
||||
}
|
91
veilid-flutter/example/integration_test/fixtures.dart
Normal file
91
veilid-flutter/example/integration_test/fixtures.dart
Normal file
|
@ -0,0 +1,91 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:mutex/mutex.dart';
|
||||
import 'package:veilid/veilid.dart';
|
||||
|
||||
class DefaultFixture {
|
||||
DefaultFixture();
|
||||
|
||||
StreamSubscription<VeilidUpdate>? _updateSubscription;
|
||||
Stream<VeilidUpdate>? _updateStream;
|
||||
|
||||
static final _fixtureMutex = Mutex();
|
||||
|
||||
Future<void> setUp() async {
|
||||
await _fixtureMutex.acquire();
|
||||
|
||||
assert(_updateStream == null, 'should not set up fixture twice');
|
||||
|
||||
final Map<String, dynamic> platformConfigJson;
|
||||
if (kIsWeb) {
|
||||
const platformConfig = VeilidWASMConfig(
|
||||
logging: VeilidWASMConfigLogging(
|
||||
performance: VeilidWASMConfigLoggingPerformance(
|
||||
enabled: true,
|
||||
level: VeilidConfigLogLevel.debug,
|
||||
logsInTimings: true,
|
||||
logsInConsole: false,
|
||||
),
|
||||
api: VeilidWASMConfigLoggingApi(
|
||||
enabled: true,
|
||||
level: VeilidConfigLogLevel.info,
|
||||
)));
|
||||
platformConfigJson = platformConfig.toJson();
|
||||
} else {
|
||||
const platformConfig = VeilidFFIConfig(
|
||||
logging: VeilidFFIConfigLogging(
|
||||
terminal: VeilidFFIConfigLoggingTerminal(
|
||||
enabled: false,
|
||||
level: VeilidConfigLogLevel.debug,
|
||||
),
|
||||
otlp: VeilidFFIConfigLoggingOtlp(
|
||||
enabled: false,
|
||||
level: VeilidConfigLogLevel.trace,
|
||||
grpcEndpoint: 'localhost:4317',
|
||||
serviceName: 'Veilid Tests',
|
||||
),
|
||||
api: VeilidFFIConfigLoggingApi(
|
||||
enabled: true,
|
||||
level: VeilidConfigLogLevel.info,
|
||||
)));
|
||||
platformConfigJson = platformConfig.toJson();
|
||||
}
|
||||
Veilid.instance.initializeVeilidCore(platformConfigJson);
|
||||
|
||||
final defaultConfig = await getDefaultVeilidConfig(
|
||||
isWeb: kIsWeb, programName: 'Veilid Tests');
|
||||
|
||||
final updateStream =
|
||||
_updateStream = await Veilid.instance.startupVeilidCore(defaultConfig);
|
||||
if (_updateStream == null) {
|
||||
throw Exception('failed to start up veilid core');
|
||||
}
|
||||
|
||||
_updateSubscription = updateStream.listen((update) {
|
||||
if (update is VeilidLog) {
|
||||
} else if (update is VeilidUpdateAttachment) {
|
||||
} else if (update is VeilidUpdateConfig) {
|
||||
} else if (update is VeilidUpdateNetwork) {
|
||||
} else if (update is VeilidAppMessage) {
|
||||
} else if (update is VeilidAppCall) {
|
||||
} else if (update is VeilidUpdateValueChange) {
|
||||
} else {
|
||||
throw Exception('unexpected update: $update');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> tearDown() async {
|
||||
assert(_updateStream != null, 'should not tearDown without setUp');
|
||||
|
||||
final cancelFut = _updateSubscription?.cancel();
|
||||
await Veilid.instance.shutdownVeilidCore();
|
||||
await cancelFut;
|
||||
|
||||
_updateSubscription = null;
|
||||
_updateStream = null;
|
||||
|
||||
_fixtureMutex.release();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:veilid/default_config.dart';
|
||||
|
||||
Future<void> testVeilidConfigDefaults() async {
|
||||
const programName = 'Veilid Tests';
|
||||
final defaultConfig =
|
||||
await getDefaultVeilidConfig(isWeb: kIsWeb, programName: programName);
|
||||
assert(defaultConfig.programName == programName, 'program name should match');
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue