mastodon_vk_reposter/test/server_test.dart
2022-04-21 05:59:37 +00:00

33 lines
815 B
Dart

import 'package:http/http.dart';
import 'package:test/test.dart';
import 'package:test_process/test_process.dart';
void main() {
final port = '8080';
final host = 'http://0.0.0.0:$port';
setUp(() async {
await TestProcess.start(
'dart',
['run', 'bin/server.dart'],
environment: {'PORT': port},
);
});
test('Root', () async {
final response = await get(Uri.parse(host + '/'));
expect(response.statusCode, 200);
expect(response.body, 'Hello, World!\n');
});
test('Echo', () async {
final response = await get(Uri.parse(host + '/echo/hello'));
expect(response.statusCode, 200);
expect(response.body, 'hello\n');
});
test('404', () async {
final response = await get(Uri.parse(host + '/foobar'));
expect(response.statusCode, 404);
});
}