Skip to content

Commit d9763a8

Browse files
authored
docs(examples): add hello world example (#233)
1 parent 4ba98da commit d9763a8

File tree

8 files changed

+97
-0
lines changed

8 files changed

+97
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: examples/hello_world
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
pull_request:
9+
paths:
10+
- "examples/hello_world/routes/**"
11+
- "examples/hello_world/lib/**"
12+
- "examples/hello_world/test/**"
13+
- ".github/workflows/examples_hello_world.yaml"
14+
branches:
15+
- main
16+
17+
jobs:
18+
build:
19+
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_package.yml@v1
20+
with:
21+
working_directory: examples/hello_world
22+
analyze_directories: "routes test"
23+
report_on: "routes"

examples/hello_world/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# See https://www.dartlang.org/guides/libraries/private-files
2+
3+
# Files and directories created by pub
4+
.dart_tool/
5+
.packages
6+
pubspec.lock
7+
8+
# Files and directories created by dart_frog
9+
build/
10+
.dart_frog
11+
12+
# Test related files
13+
coverage/

examples/hello_world/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Hello World
2+
3+
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link]
4+
[![License: MIT][license_badge]][license_link]
5+
6+
A hello world example app built with `dart_frog`.
7+
8+
[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg
9+
[license_link]: https://opensource.org/licenses/MIT
10+
[very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg
11+
[very_good_analysis_link]: https://pub.dev/packages/very_good_analysis
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include: package:very_good_analysis/analysis_options.3.0.1.yaml
2+
analyzer:
3+
exclude:
4+
- build/**
5+
linter:
6+
rules:
7+
file_names: false
1.67 KB
Binary file not shown.

examples/hello_world/pubspec.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: hello_world
2+
description: A hello world example app built with Dart Frog.
3+
version: 1.0.0+1
4+
publish_to: none
5+
6+
environment:
7+
sdk: ">=2.17.0 <3.0.0"
8+
9+
dependencies:
10+
dart_frog: ^0.0.1-dev
11+
12+
dev_dependencies:
13+
mocktail: ^0.3.0
14+
test: ^1.19.2
15+
very_good_analysis: ^3.0.1
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import 'package:dart_frog/dart_frog.dart';
2+
3+
Response onRequest(RequestContext context) {
4+
return Response(body: 'Welcome to Dart Frog!');
5+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'dart:io';
2+
3+
import 'package:dart_frog/dart_frog.dart';
4+
import 'package:mocktail/mocktail.dart';
5+
import 'package:test/test.dart';
6+
7+
import '../../routes/index.dart' as route;
8+
9+
class _MockRequestContext extends Mock implements RequestContext {}
10+
11+
void main() {
12+
group('GET /', () {
13+
test('responds with a 200 and "Welcome to Dart Frog!".', () {
14+
final context = _MockRequestContext();
15+
final response = route.onRequest(context);
16+
expect(response.statusCode, equals(HttpStatus.ok));
17+
expect(
18+
response.body(),
19+
completion(equals('Welcome to Dart Frog!')),
20+
);
21+
});
22+
});
23+
}

0 commit comments

Comments
 (0)