Skip to content

Commit 19bb065

Browse files
committed
update
1 parent 1b6ed26 commit 19bb065

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

spec/03-plugins/11-correlation-id/02-schema_spec.lua

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -79,38 +79,39 @@ describe("Plugin: correlation-id (schema) #a [#" .. strategy .."]", function()
7979
local res, err = db.connector:query(sql)
8080
assert.is_nil(err)
8181
assert.is_nil(res[1].generator)
82-
8382
res = admin_client:get("/plugins")
8483
res = cjson.decode(assert.res_status(200, res))
8584
assert.equals(res.data[1].config.generator, "uuid#counter")
8685
end)
8786
end)
8887

89-
for _, rpc_sync in ipairs { "off", "on" } do
90-
for _, cluster_rpc in ipairs { "off", "on" } do
88+
for _, v in ipairs({ {"off", "off"}, {"on", "off"}, {"on", "on"}, }) do
89+
local rpc, rpc_sync = v[1], v[2]
9190
describe("in hybrid mode" .. " rpc_sync=" .. rpc_sync, function()
9291
local route
9392
local plugin_name = "correlation-id"
94-
local bp, db = helpers.get_db_utils(strategy, { "plugins", "workspaces", })
95-
local ws = db.workspaces:select_by_name("default")
96-
local plugin_id = uuid.generate_v4()
97-
plugin_id = uuid.generate_v4()
98-
local sql = render([[
99-
INSERT INTO plugins (id, name, config, enabled, ws_id) VALUES
100-
('$(ID)', '$(PLUGIN_NAME)', $(CONFIG)::jsonb, TRUE, '$(WS_ID)');
101-
COMMIT;
102-
]], {
103-
ID = plugin_id,
104-
PLUGIN_NAME = plugin_name,
105-
CONFIG = pgmoon_json.encode_json(plugin_config),
106-
WS_ID = ws.id,
107-
})
108-
109-
local res, err = db.connector:query(sql)
110-
assert.is_nil(err)
111-
assert.is_not_nil(res)
93+
local bp, db, ws, plugin_id
11294

11395
lazy_setup(function()
96+
-- copy from outer lazy_setup, to avoid database reused.
97+
bp, db = helpers.get_db_utils(strategy, { "plugins", "workspaces", })
98+
ws = db.workspaces:select_by_name("default")
99+
plugin_id = uuid.generate_v4()
100+
local sql = render([[
101+
INSERT INTO plugins (id, name, config, enabled, ws_id) VALUES
102+
('$(ID)', '$(PLUGIN_NAME)', $(CONFIG)::jsonb, TRUE, '$(WS_ID)');
103+
COMMIT;
104+
]], {
105+
ID = plugin_id,
106+
PLUGIN_NAME = plugin_name,
107+
CONFIG = pgmoon_json.encode_json(plugin_config),
108+
WS_ID = ws.id,
109+
})
110+
111+
local res, err = db.connector:query(sql)
112+
assert.is_nil(err)
113+
assert.is_not_nil(res)
114+
114115
route = bp.routes:insert({
115116
hosts = {"example.com"},
116117
})
@@ -145,7 +146,7 @@ describe("Plugin: correlation-id (schema) #a [#" .. strategy .."]", function()
145146
cluster_listen = "127.0.0.1:9005",
146147
nginx_conf = "spec/fixtures/custom_nginx.template",
147148
cluster_rpc_sync = rpc_sync,
148-
cluster_rpc = cluster_rpc
149+
cluster_rpc = rpc
149150
}))
150151

151152
assert(helpers.start_kong({
@@ -158,7 +159,7 @@ describe("Plugin: correlation-id (schema) #a [#" .. strategy .."]", function()
158159
proxy_listen = "0.0.0.0:9002",
159160
status_listen = "127.0.0.1:9100",
160161
cluster_rpc_sync = rpc_sync,
161-
cluster_rpc = cluster_rpc
162+
cluster_rpc = rpc
162163
}))
163164
end)
164165

@@ -208,6 +209,5 @@ describe("Plugin: correlation-id (schema) #a [#" .. strategy .."]", function()
208209
proxy_client:close()
209210
end)
210211
end)
211-
end -- for rpc_sync
212-
end -- for cluster_sync
212+
end -- for rpc, rpc_sync
213213
end)

0 commit comments

Comments
 (0)