forked from Kong/kong
-
Notifications
You must be signed in to change notification settings - Fork 0
/
00-sanity.t
84 lines (66 loc) · 1.85 KB
/
00-sanity.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
77
78
79
80
81
82
83
84
use strict;
use warnings FATAL => 'all';
use Test::Nginx::Socket::Lua;
use t::Util;
#repeat_each(2);
plan tests => repeat_each() * (blocks() * 3);
run_tests();
__DATA__
=== TEST 1: PDK loads latest version by default
--- http_config eval: $t::Util::HttpConfig
--- config
location = /t {
content_by_lua_block {
local PDK = require "kong.pdk"
ngx.say("major_versions: ", type(PDK.major_versions))
ngx.say("instantiating pdk")
local pdk = PDK.new()
ngx.say("pdk.pdk_major_version: ", pdk.pdk_major_version)
ngx.say("is latest: ", pdk.pdk_major_version == PDK.major_versions.latest)
}
}
--- request
GET /t
--- response_body_like chomp
major_versions: table
instantiating pdk
pdk\.pdk_major_version: \d+
is latest: true
--- no_error_log
[error]
=== TEST 2: has pdk_major_version and pdk_version fields
--- http_config eval: $t::Util::HttpConfig
--- config
location = /t {
content_by_lua_block {
local PDK = require "kong.pdk"
local pdk = PDK.new()
ngx.say("pdk_major_version: ", pdk.pdk_major_version)
ngx.say("pdk_version: ", pdk.pdk_version)
}
}
--- request
GET /t
--- response_body_like chomp
pdk_major_version: \d+
pdk_version: \d+\.\d+.\d+
--- no_error_log
[error]
=== TEST 3: can load given major version
--- SKIP: skip me since 1st release will only have version 0
--- http_config eval: $t::Util::HttpConfig
--- config
location = /t {
content_by_lua_block {
local PDK = require "kong.pdk"
local pdk_latest = PDK.new()
local pdk_previous = PDK.new(0)
ngx.say("different version: ", pdk_latest.pdk_major_version ~= pdk_previous.pdk_major_version)
}
}
--- request
GET /t
--- response_body
different version: true
--- no_error_log
[error]