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 'fave_reads.dart'; | |
import './controller/books_controller.dart'; | |
import './utils/utils.dart'; // 👈👈👈 | |
class FaveReadsSink extends RequestSink { | |
//... | |
//... | |
@override | |
Future willOpen() async { | |
await createDatabaseSchema(ManagedContext.defaultContext, config.database.isTemporary); |
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(); | |
}); |
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
group("books controller", () { | |
test("GET /books returns list of books", () async { | |
// Arrange | |
var request = app.client.request("/books"); | |
// Act | |
var response = await request.get(); | |
// Assert | |
expectResponse(response, 200, |
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
test("POST /books creates a new book", () async { | |
var request = app.client.request("/books") | |
..json = { | |
"title": "Dart: Scalable Application Development", | |
"author": "Davy Mitchell, Sergey Akopkokhyants, Ivo Balbaert", | |
"year": 2007 | |
}; | |
expectResponse(await request.post(), 200, | |
body: partial({ | |
"id": 4, // updated primary key from db |
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(); | |
}); |
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
void main() { | |
print("This is my first Dart program."); | |
} |
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 "dart:io"; | |
void main() { | |
HttpServer.bind("localhost", 8080).then((HttpServer server) { | |
server.listen((HttpRequest request) { | |
request.response.write("Hello world"); | |
request.response.close(); | |
}); | |
}); | |
} |
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 'dart:io'; | |
import 'dart:async'; | |
import 'dart:convert'; | |
main() async { | |
Uri apiUrl = Uri.parse("https://swapi.co/api/people/1"); // Star Wars API | |
HttpClientRequest request = await new HttpClient().getUrl(apiUrl); | |
HttpClientResponse response = await request.close(); |
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 ‘../fave_reads.dart’; | |
import ‘./author.dart’; | |
class Book extends ManagedObject<_Book> implements _Book {} | |
class _Book { | |
@managedPrimaryKey | |
int id; | |
String title; |