Skip to content

Instantly share code, notes, and snippets.

@graphicbeacon
Created May 30, 2018 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graphicbeacon/a77bee5bbb56e596efd347601b01adb8 to your computer and use it in GitHub Desktop.
Save graphicbeacon/a77bee5bbb56e596efd347601b01adb8 to your computer and use it in GitHub Desktop.
Sample code for "Building RESTful Web APIs with Dart, Aqueduct and PostgreSQL (Part 4)" post on Medium (6)
import 'harness/app.dart';
import 'package:fave_reads/model/book.dart';
Future main() async {
TestApplication app = new TestApplication();
setUpAll(() async {
await app.start();
});
tearDownAll(() async {
await app.stop();
});
setUp(() async {
// Populate DB
var books = [
new Book()
..title = "Head First Design Patterns"
..author = "Eric Freeman"
..year = 2004,
new Book()
..title = "Clean Code: A handbook of Agile Software Craftsmanship"
..author = "Robert C. Martin"
..year = 2008,
new Book()
..title = "Code Complete: A Practical Handbook of Software Construction"
..author = "Steve McConnell"
..year = 2004
];
await Future.forEach(books, (Book b) async {
var query = new Query<Book>()..values = b;
query.insert();
});
});
tearDown(() async {
await app.discardPersistentData();
});
//...tests to go here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment