Created
May 30, 2018 18:42
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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