Mercurial > hg > nginx-tests
comparison js_request_body.t @ 1342:5833f3b7a884
Tests: adapted js_request_body.t for renamed property.
r.body -> r.requestBody.
author | Dmitry Volyntsev <xeioex@nginx.com> |
---|---|
date | Wed, 13 Jun 2018 13:57:38 +0300 |
parents | d6daf03478ad |
children | 9d579fc770a6 |
comparison
equal
deleted
inserted
replaced
1341:15f0d9412b22 | 1342:5833f3b7a884 |
---|---|
1 #!/usr/bin/perl | 1 #!/usr/bin/perl |
2 | 2 |
3 # (C) Dmitry Volyntsev. | 3 # (C) Dmitry Volyntsev |
4 # (C) Nginx, Inc. | 4 # (C) Nginx, Inc. |
5 | 5 |
6 # Tests for http JavaScript module, req.body method. | 6 # Tests for http njs module, req.requestBody method. |
7 | 7 |
8 ############################################################################### | 8 ############################################################################### |
9 | 9 |
10 use warnings; | 10 use warnings; |
11 use strict; | 11 use strict; |
59 } | 59 } |
60 | 60 |
61 EOF | 61 EOF |
62 | 62 |
63 $t->write_file('test.js', <<EOF); | 63 $t->write_file('test.js', <<EOF); |
64 function test_njs(req, res) { | 64 function test_njs(r) { |
65 res.return(200, njs.version); | 65 r.return(200, njs.version); |
66 } | 66 } |
67 | 67 |
68 function test_body(req) { | 68 function test_body(r) { |
69 try { | 69 try { |
70 var body = req.body; | 70 var body = r.requestBody; |
71 req.response.return(200, body); | 71 r.return(200, body); |
72 | 72 |
73 } catch (e) { | 73 } catch (e) { |
74 req.response.return(500, e.message); | 74 r.return(500, e.message); |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 EOF | 78 EOF |
79 | 79 |
80 $t->try_run('no njs request body')->plan(3); | 80 $t->try_run('no njs request body')->plan(3); |
81 | 81 |
82 ############################################################################### | 82 ############################################################################### |
83 | 83 |
84 TODO: { | 84 TODO: { |
85 local $TODO = 'not yet' | 85 local $TODO = 'deprecated api' |
86 unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.2.1'; | 86 unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.2.2'; |
87 like(http_post('/body'), qr/REQ-BODY/, 'request body'); | 87 like(http_post('/body'), qr/REQ-BODY/, 'request body'); |
88 like(http_post('/in_file'), qr/request body is in a file/, | 88 like(http_post('/in_file'), qr/request body is in a file/, |
89 'request body in file'); | 89 'request body in file'); |
90 like(http_post_big('/body'), qr/200.*^(1234567890){1024}$/ms, | 90 like(http_post_big('/body'), qr/200.*^(1234567890){1024}$/ms, |
91 'request body big'); | 91 'request body big'); |