ci: fix failing vweb test, increase timeout for vweb_test_server.v, add VWEB_LOGFILE

This commit is contained in:
Delyan Angelov 2021-01-02 13:21:30 +02:00
parent 01e098aa77
commit d912ff165b
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED
3 changed files with 16 additions and 7 deletions

View file

@ -7,8 +7,9 @@ import io
const (
sport = 12380
exit_after_time = 5000 // milliseconds
exit_after_time = 7000 // milliseconds
vexe = os.getenv('VEXE')
vweb_logfile = os.getenv('VWEB_LOGFILE')
vroot = os.dir(vexe)
serverexe = os.join_path(os.cache_dir(), 'vweb_test_server.exe')
tcp_r_timeout = 30 * time.second
@ -30,7 +31,13 @@ fn test_a_simple_vweb_app_can_be_compiled() {
}
fn test_a_simple_vweb_app_runs_in_the_background() {
suffix := $if windows { '' } $else { ' > /dev/null &' }
mut suffix := ''
$if !windows {
suffix = ' > /dev/null &'
}
if vweb_logfile != '' {
suffix = ' 2>> $vweb_logfile >> $vweb_logfile &'
}
server_exec_cmd := '$serverexe $sport $exit_after_time $suffix'
$if debug_net_socket_client ? {
eprintln('running:\n$server_exec_cmd')
@ -161,7 +168,7 @@ fn test_http_client_json_post() {
json_for_ouser := json.encode(ouser)
mut x := http.post_json('http://127.0.0.1:$sport/json_echo', json_for_ouser) or { panic(err) }
$if debug_net_socket_client ? {
eprintln('json response: $x')
eprintln('/json_echo endpoint response: $x')
}
assert x.headers['Content-Type'] == 'application/json'
assert x.text == json_for_ouser
@ -170,7 +177,7 @@ fn test_http_client_json_post() {
//
x = http.post_json('http://127.0.0.1:$sport/json', json_for_ouser) or { panic(err) }
$if debug_net_socket_client ? {
eprintln('json response: $x')
eprintln('/json endpoint response: $x')
}
assert x.headers['Content-Type'] == 'application/json'
assert x.text == json_for_ouser

View file

@ -80,6 +80,7 @@ pub fn (mut app App) user_repo_settings(username string, repository string) vweb
[post]
['/json_echo']
pub fn (mut app App) json_echo() vweb.Result {
eprintln('>>>>> received http request at /json_echo is: $app.req')
app.set_content_type(app.req.headers['Content-Type'])
return app.ok(app.req.data)
}
@ -87,6 +88,7 @@ pub fn (mut app App) json_echo() vweb.Result {
// Make sure [post] works without the path
[post]
pub fn (mut app App) json() vweb.Result {
eprintln('>>>>> received http request at /json is: $app.req')
app.set_content_type(app.req.headers['Content-Type'])
return app.ok(app.req.data)
}