2024-09-23 01:44:59 +00:00
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'package:platform_container/mirrors.dart';
|
2024-09-25 04:04:57 +00:00
|
|
|
import 'package:platform_core/core.dart';
|
|
|
|
import 'package:platform_core/http.dart';
|
2024-11-11 19:49:32 +00:00
|
|
|
import 'package:platform_testing/http.dart';
|
2024-09-23 01:44:59 +00:00
|
|
|
|
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
test('preinjects functions', () async {
|
2024-09-28 23:14:48 +00:00
|
|
|
var app = Application(reflector: MirrorsReflector())
|
2024-09-23 01:44:59 +00:00
|
|
|
..configuration['foo'] = 'bar'
|
|
|
|
..get('/foo', ioc(echoAppFoo));
|
|
|
|
app.optimizeForProduction(force: true);
|
|
|
|
print(app.preContained);
|
|
|
|
expect(app.preContained.keys, contains(echoAppFoo));
|
|
|
|
|
|
|
|
var rq = MockHttpRequest('GET', Uri(path: '/foo'));
|
|
|
|
await rq.close();
|
2024-09-28 23:14:48 +00:00
|
|
|
await PlatformHttp(app).handleRequest(rq);
|
2024-09-23 01:44:59 +00:00
|
|
|
var rs = rq.response;
|
|
|
|
var body = await rs.transform(utf8.decoder).join();
|
|
|
|
expect(body, json.encode('bar'));
|
2024-09-23 04:39:29 +00:00
|
|
|
}, skip: 'Protevus no longer has to preinject functions');
|
2024-09-23 01:44:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
String echoAppFoo(String foo) => foo;
|