forked from 3scale/APIcast
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdeprecation-warnings.t
76 lines (70 loc) · 1.62 KB
/
deprecation-warnings.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
use lib 't';
use Test::APIcast::Blackbox 'no_plan';
# Can't run twice because the deprecation msg shows only once per require.
repeat_each(1);
run_tests();
__DATA__
=== TEST 1: deprecation warnings
APIcast should emit deprecation warnings when loading renamed files.
--- configuration
{ "services": [
{ "proxy":
{ "policy_chain": [
{ "name": "apicast.policy.upstream",
"configuration": {
"rules": [{
"regex": "/",
"url": "http://test:$TEST_NGINX_SERVER_PORT"
}]
}
}
] }
}
] }
--- upstream
location /{
content_by_lua_block {
require('apicast')
ngx.exit(200)
}
}
--- request
GET /echo?user_key=foo
--- error_code: 200
--- no_error_log
[error]
--- grep_error_log eval: qr/DEPRECATION:[^,]+/
--- grep_error_log_out
DEPRECATION: file renamed - change: require("apicast") to: require("apicast.policy.apicast")
=== TEST 2: deprecation warnings
APIcast should emit deprecation warnings when loading not namespaced code.
--- configuration
{ "services": [
{ "proxy":
{ "policy_chain": [
{ "name": "apicast.policy.upstream",
"configuration": {
"rules": [{
"regex": "/",
"url": "http://test:$TEST_NGINX_SERVER_PORT"
}]
}
}
] }
}
] }
--- upstream
location /{
content_by_lua_block {
require('cli')
ngx.exit(200)
}
}
--- request
GET /echo?user_key=foo
--- error_code: 200
--- no_error_log
[error]
--- grep_error_log eval: qr/DEPRECATION:[^,]+/
--- grep_error_log_out
DEPRECATION: when loading apicast code use correct prefix: require("apicast.cli")