platform/test/services/users_test.dart

43 lines
1.1 KiB
Dart
Raw Normal View History

2016-12-10 18:51:02 +00:00
import 'dart:io';
import 'package:angel/angel.dart';
import 'package:angel_test/angel_test.dart';
import 'package:test/test.dart';
// Angel also includes facilities to make testing easier.
//
// `package:angel_test` ships a client that can test
// both plain HTTP and WebSockets.
//
// Tests do not require your server to actually be mounted on a port,
// so they will run faster than they would in other frameworks, where you
// would have to first bind a socket, and then account for network latency.
//
// See the documentation here:
// https://github.com/angel-dart/test
//
// If you are unfamiliar with Dart's advanced testing library, you can read up
// here:
// https://github.com/dart-lang/test
2016-12-10 18:51:02 +00:00
main() async {
TestClient client;
setUp(() async {
var app = await createServer();
2016-12-25 17:23:48 +00:00
client = await connectTo(app);
2016-12-10 18:51:02 +00:00
});
tearDown(() async {
await client.close();
});
test('index users', () async {
// Request a resource at the given path.
var response = await client.get('/api/users');
2016-12-10 18:51:02 +00:00
// By default, we locked this away from the Internet...
// Expect a 403 response.
2016-12-10 18:51:02 +00:00
expect(response, hasStatus(HttpStatus.FORBIDDEN));
});
}