8000 Add cram test for the examples by Willenbrink · Pull Request #396 · aantron/dream · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add cram test for the examples #396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(lang dune 2.7)
(lang dune 3.0)
2 changes: 1 addition & 1 deletion example/4-counter/counter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ let () =
@@ count_requests
@@ Dream.router [
Dream.get "/" (fun _ ->
Dream.html (Printf.sprintf "Saw %i request(s)!" !count));
Dream.html (Printf.sprintf "Responding to the %i. request!" !count));
]
4 changes: 4 additions & 0 deletions test/cram/1-hello.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$ hello &> /dev/null &
$ $CURL localhost:8080
Good morning, world!
$ pkill -P $$
4 changes: 4 additions & 0 deletions test/cram/2-middleware.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$ middleware &> /dev/null &
$ $CURL localhost:8080
Good morning, world!
$ pkill -P $$
4 changes: 4 additions & 0 deletions test/cram/3-router.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$ router &> /dev/null &
$ $CURL localhost:8080/echo/hello-world
hello-world
$ pkill -P $$
6 changes: 6 additions & 0 deletions test/cram/4-counter.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$ counter &> /dev/null &
$ $CURL localhost:8080
Responding to the 1. request!
$ $CURL localhost:8080
Responding to the 2. request!
$ pkill -P $$
7 changes: 7 additions & 0 deletions test/cram/5-promise.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$ promise &> /dev/null &
$ $CURL localhost:8080
0 request(s) successful<br> 0 request(s) failed
$ curl --no-progress-meter localhost:8080/fail
$ $CURL localhost:8080
1 request(s) successful<br> 1 request(s) failed
$ pkill -P $$
4 changes: 4 additions & 0 deletions test/cram/6-echo.t
8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$ echo-server &> /dev/null &
$ $CURL localhost:8080/echo --data "Hello, world!"
Hello, world!
$ pkill -P $$
9 changes: 9 additions & 0 deletions test/cram/7-template.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$ template &> /dev/null &
$ $CURL localhost:8080/hello-world
<html>
<body>
<h1>The URL parameter was hello-world!</h1>
</body>
</html>

$ pkill -P $$
302 changes: 302 additions & 0 deletions test/cram/8-debug.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,302 @@
$ debug &> /dev/null &
$ $CURL localhost:8080/bad | sed 's/::1:.*/::1:<omitted>/' | sed 's/dream.request_id: [^<]*/dream.request_id: <omitted>/'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<style>

body {
color: rgb(17, 24, 39);
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif;
margin: 3rem 2rem;
}

h1 {
font-weight: 600;
margin: 0;
}

h2 {
font-weight: normal;
}

h3 {
font-size: 16px;
font-weight: normal;
border: 1px solid #ddd;
margin: 0;
padding: 1rem 1.5rem;
}

pre {
background-color: rgb(31, 41, 55);
color: white;
font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
font-size: 16px;
line-height: 1.5;
margin: 0;
padding: 1rem;
}

</style>
<title>400 Bad Request</title>
</head>

<body>
<h1>An error occured!</h1>
<h2>400 Bad Request</h2>
<p>
This error page has been generated by Dream's error handler.<br />
Remember to turn debugging mode off when deploying your application in
production.
</p>
<h3>Debug Dump</h3>
<pre><code>400 Bad Request

From: Application
Blame: Client
Severity: Warning

Client: ::1:<omitted>

GET /bad
Host: localhost:8080
User-Agent: curl/8.9.1
Accept: */*

dream.client: ::1:<omitted>
dream.tls: false
dream.request_id: <omitted>
dream.fd: 6
dream.params: </code></pre>
</body>
</html>
$ $CURL localhost:8080/fail | sed 's/::1:.*/::1:<omitted>/' | sed 's/dream.request_id: [^<]*/dream.request_id: <omitted>/'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<style>

body {
color: rgb(17, 24, 39);
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif;
margin: 3rem 2rem;
}

h1 {
font-weight: 600;
margin: 0;
}

h2 {
font-weight: normal;
}

h3 {
font-size: 16px;
font-weight: normal;
border: 1px solid #ddd;
margin: 0;
padding: 1rem 1.5rem;
}

pre {
background-color: rgb(31, 41, 55);
color: white;
font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
font-size: 16px;
line-height: 1.5;
margin: 0;
padding: 1rem;
}

</style>
<title>500 Internal Server Error</title>
</head>

<body>
<h1>An error occured!</h1>
<h2>500 Internal Server Error</h2>
<p>
This error page has been generated by Dream's error handler.<br />
Remember to turn debugging mode off when deploying your application in
production.
</p>
<h3>Debug Dump</h3>
<pre><code>Failure(&quot;The Web app failed!&quot;)
Raised at Stdlib__Map.Make.find in file &quot;map.ml&quot;, line 141, characters 10-25
Called from Logs.Tag.find in file &quot;src/logs.ml&quot;, line 153, characters 14-32

From: Application
Blame: Server
Severity: Error

Client: ::1:<omitted>

GET /fail
Host: localhost:8080
User-Agent: curl/8.9.1
Accept: */*

dream.client: ::1:<omitted>
dream.tls: false
dream.request_id: <omitted>
dream.fd: 6
dream.params: </code></pre>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<style>

body {
color: rgb(17, 24, 39);
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif;
margin: 3rem 2rem;
}

h1 {
font-weight: 600;
margin: 0;
}

h2 {
font-weight: normal;
}

h3 {
font-size: 16px;
font-weight: normal;
border: 1px solid #ddd;
margin: 0;
padding: 1rem 1.5rem;
}

pre {
background-color: rgb(31, 41, 55);
color: white;
font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
font-size: 16px;
line-height: 1.5;
margin: 0;
padding: 1rem;
}

</style>
<title>500 Internal Server Error</title>
</head>

<body>
<h1>An error occured!</h1>
<h2>500 Internal Server Error</h2>
<p>
This error page has been generated by Dream's error handler.<br />
Remember to turn debugging mode off when deploying your application in
production.
</p>
<h3>Debug Dump</h3>
<pre><code>Failure(&quot;The Web app failed!&quot;)
Raised at Stdlib__Map.Make.find in file &quot;map.ml&quot;, line 141, characters 10-25
Called from Logs.Tag.find in file &quot;src/logs.ml&quot;, line 153, characters 14-32

From: Application
Blame: Server
Severity: Error

Client: ::1:<omitted>

GET /fail
Host: localhost:8080
User-Agent: curl/8.9.1
Accept: */*

dream.client: ::1:<omitted>
dream.tls: false
dream.request_id: <omitted>
dream.fd: 6
dream.params: </code></pre>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<style>

body {
color: rgb(17, 24, 39);
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif;
margin: 3rem 2rem;
}

h1 {
font-weight: 600;
margin: 0;
}

h2 {
font-weight: normal;
}

h3 {
font-size: 16px;
font-weight: normal;
border: 1px solid #ddd;
margin: 0;
padding: 1rem 1.5rem;
}

pre {
background-color: rgb(31, 41, 55);
color: white;
font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
font-size: 16px;
line-height: 1.5;
margin: 0;
padding: 1rem;
}

</style>
<title>500 Internal Server Error</title>
</head>

<body>
<h1>An error occured!</h1>
<h2>500 Internal Server Error</h2>
<p>
This error page has been generated by Dream's error handler.<br />
Remember to turn debugging mode off when deploying your application in
production.
</p>
<h3>Debug Dump</h3>
<pre><code>Failure(&quot;The Web app failed!&quot;)
Raised at Stdlib__Map.Make.find in file &quot;map.ml&quot;, line 141, characters 10-25
Called from Logs.Tag.find in file &quot;src/logs.ml&quot;, line 153, characters 14-32

From: Application
Blame: Server
Severity: Error

Client: ::1:<omitted>

GET /fail
Host: localhost:8080
User-Agent: curl/8.9.1
Accept: */*

dream.client: ::1:<omitted>
dream.tls: false
dream.request_id: <omitted>
dream.fd: 6
dream.params: </code></pre>
</body>
</html>
$ pkill -P $$
Loading
Loading
0