File tree Expand file tree Collapse file tree 13 files changed +228
-2
lines changed Expand file tree Collapse file tree 13 files changed +228
-2
lines changed Original file line number Diff line number Diff line change
1
+ name : Docker Tests
2
+
3
+ on :
4
+ workflow_call :
5
+ inputs :
6
+ setup :
7
+ required : false
8
+ type : string
9
+ default : " "
10
+ test_directory :
11
+ required : false
12
+ type : string
13
+ default : " e2e"
14
+ working_directory :
15
+ required : false
16
+ type : string
17
+ default : " ."
18
+
19
+ jobs :
20
+ test :
21
+ runs-on : ubuntu-latest
22
+ defaults :
23
+ run :
24
+ working-directory : ${{inputs.working_directory}}
25
+
26
+ steps :
27
+ - name : 📚 Git Checkout
28
+ uses : actions/checkout@v3
29
+
30
+ - name : 🎯 Setup Dart
31
+ uses : dart-lang/setup-dart@v1
32
+
33
+ - name : ⚙️ Run Setup
34
+ if : " ${{inputs.setup != ''}}"
35
+ run : ${{inputs.setup}}
36
+
37
+ - name : 📦 Install Dependencies
38
+ run : dart pub get
39
+
40
+ - name : 🐸 Dart Frog Build
41
+ run : dart_frog build
42
+
43
+ - name : 🐳 Build Docker Image
44
+ run : docker build -q build -t e2e-image
45
+
46
+ - name : ⚡️ Run Docker Image
47
+ run : docker run -d -p 8080:8080 --name e2e --rm e2e-image
48
+
49
+ - name : 🧪 Run Docker Tests
50
+ run : dart test ${{inputs.test_directory}}
51
+
52
+ - name : 🧹 Docker Cleanup
53
+ if : success() || failure()
54
+ run : |
55
+ docker stop e2e
56
+ docker image rm e2e-image
Original file line number Diff line number Diff line change 10
10
- " examples/counter/routes/**"
11
11
- " examples/counter/lib/**"
12
12
- " examples/counter/test/**"
13
+ - " examples/counter/e2e/**"
13
14
- " .github/workflows/examples_counter.yaml"
14
15
- " packages/dart_frog/lib/**"
15
16
- " packages/dart_frog/pubspec.yaml"
23
24
working_directory : examples/counter
24
25
analyze_directories : " routes test"
25
26
report_on : " routes"
27
+
28
+ docker :
29
+ uses : ./.github/workflows/.docker_tests.yaml
30
+ with :
31
+ setup : rm pubspec_overrides.yaml && dart pub global activate --source path ../../packages/dart_frog_cli
32
+ working_directory : examples/counter
Original file line number Diff line number Diff line change 10
10
- " examples/echo/routes/**"
11
11
- " examples/echo/lib/**"
12
12
- " examples/echo/test/**"
13
+ - " examples/echo/e2e/**"
13
14
- " .github/workflows/examples_echo.yaml"
14
15
- " packages/dart_frog/lib/**"
15
16
- " packages/dart_frog/pubspec.yaml"
23
24
working_directory : examples/echo
24
25
analyze_directories : " routes test"
25
26
report_on : " routes"
27
+
28
+ docker :
29
+ uses : ./.github/workflows/.docker_tests.yaml
30
+ with :
31
+ setup : rm pubspec_overrides.yaml && dart pub global activate --source path ../../packages/dart_frog_cli
32
+ working_directory : examples/echo
Original file line number Diff line number Diff line change 10
10
- " examples/hello_world/routes/**"
11
11
- " examples/hello_world/lib/**"
12
12
- " examples/hello_world/test/**"
13
+ - " examples/hello_world/e2e/**"
13
14
- " .github/workflows/examples_hello_world.yaml"
14
15
- " packages/dart_frog/lib/**"
15
16
- " packages/dart_frog/pubspec.yaml"
23
24
working_directory : examples/hello_world
24
25
analyze_directories : " routes test"
25
26
report_on : " routes"
27
+
28
+ docker :
29
+ uses : ./.github/workflows/.docker_tests.yaml
30
+ with :
31
+ setup : rm pubspec_overrides.yaml && dart pub global activate --source path ../../packages/dart_frog_cli
32
+ working_directory : examples/hello_world
Original file line number Diff line number Diff line change 12
12
- " examples/todos/test/**"
13
13
- " examples/todos/packages/**/lib/**"
14
14
- " examples/todos/packages/**/test/**"
15
+ - " examples/todos/packages/**/e2e/**"
15
16
- " .github/workflows/examples_todos.yaml"
16
17
- " packages/dart_frog/lib/**"
17
18
- " packages/dart_frog/pubspec.yaml"
26
27
analyze_directories : " routes test"
27
28
report_on : " routes"
28
29
30
+ docker :
31
+ uses : ./.github/workflows/.docker_tests.yaml
32
+ with :
33
+ setup : rm pubspec_overrides.yaml && dart pub global activate --source path ../../packages/dart_frog_cli
34
+ working_directory : examples/todos
35
+
29
36
todos_data_source :
30
37
uses : VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_package.yml@v1
31
38
with :
Original file line number Diff line number Diff line change
1
+ import 'dart:io' ;
2
+
3
+ import 'package:http/http.dart' as http;
4
+ import 'package:test/test.dart' ;
5
+
6
+ void main () {
7
+ group ('E2E' , () {
8
+ test ('GET / increments the count on each request' , () async {
9
+ const numRequests = 10 ;
10
+ for (var i = 1 ; i <= numRequests; i++ ) {
11
+ final response = await http.get (Uri .parse ('http://localhost:8080' ));
12
+ expect (response.statusCode, equals (HttpStatus .ok));
13
+ expect (
14
+ response.body,
15
+ equals ('You have requested this route $i time(s).' ),
16
+ );
17
+ }
18
+ });
19
+ });
20
+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ dependencies:
10
10
dart_frog : ^0.0.1-dev
11
11
12
12
dev_dependencies :
13
+ http : ^0.13.5
13
14
mocktail : ^0.3.0
14
15
test : ^1.19.2
15
16
very_good_analysis : ^3.0.1
Original file line number Diff line number Diff line change
1
+ import 'dart:io' ;
2
+
3
+ import 'package:http/http.dart' as http;
4
+ import 'package:test/test.dart' ;
5
+
6
+ void main () {
7
+ group ('E2E' , () {
8
+ test ('GET /<message> echos back <message>' , () async {
9
+ final messages = ['hello' , 'world' ];
10
+ for (final message in messages) {
11
+ final response = await http.get (
12
+ Uri .parse ('http://localhost:8080/$message ' ),
13
+ );
14
+ expect (response.statusCode, equals (HttpStatus .ok));
15
+ expect (response.body, equals (message));
16
+ }
17
+ });
18
+ });
19
+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ dependencies:
10
10
dart_frog : ^0.0.1-dev
11
11
12
12
dev_dependencies :
13
+ http : ^0.13.5
13
14
mocktail : ^0.3.0
14
15
test : ^1.19.2
15
16
very_good_analysis : ^3.0.1
Original file line number Diff line number Diff line change
1
+ import 'dart:io' ;
2
+
3
+ import 'package:http/http.dart' as http;
4
+ import 'package:test/test.dart' ;
5
+
6
+ void main () {
7
+ group ('E2E' , () {
8
+ test ('GET / responds with "Welcome to Dart Frog!"' , () async {
9
+ final response = await http.get (Uri .parse ('http://localhost:8080' ));
10
+ expect (response.statusCode, equals (HttpStatus .ok));
11
+ expect (response.body, equals ('Welcome to Dart Frog!' ));
12
+ });
13
+
14
+ test ('GET /favicon.ico responds with the favicon.cio' , () async {
15
+ final response = await http.get (
16
+ Uri .parse ('http://localhost:8080/favicon.ico' ),
17
+ );
18
+ expect (response.statusCode, equals (HttpStatus .ok));
19
+ expect (response.body, isNotEmpty);
20
+ });
21
+ });
22
+ }
You can’t perform that action at this time.
0 commit comments