ngx table in checks when writing unit tests not available #20

Closed
opened 2022-09-16 10:53:25 +00:00 by CSDUMMI · 4 comments
CSDUMMI commented 2022-09-16 10:53:25 +00:00 (Migrated from gitlab.com)

When writing a unit test using busted for the banmecheck I found that I could not write to the global variables available to banme.lua and thus cannot create a stub ngx table.

This is a problem, because without the ngx table the check will cause an error when run in Lua without OpenResty.

Solutions:

  1. Inject ngx to the checks (dependency injection)
  2. Do not use ngx table in checks
  3. Run tests in openresty.
When writing a unit test using busted for the `banme`check I found that I could not write to the global variables available to `banme.lua` and thus cannot create a stub `ngx` table. This is a problem, because without the `ngx` table the check will cause an error when run in Lua without OpenResty. Solutions: 1. Inject `ngx` to the checks (dependency injection) 2. Do not use `ngx` table in checks 3. Run tests in openresty.
CSDUMMI commented 2022-09-16 10:53:25 +00:00 (Migrated from gitlab.com)

assigned to @CSDUMMI

assigned to @CSDUMMI
CSDUMMI commented 2022-09-16 10:53:48 +00:00 (Migrated from gitlab.com)

mentioned in merge request !17

mentioned in merge request !17
CSDUMMI commented 2022-09-20 14:17:23 +00:00 (Migrated from gitlab.com)

I used dependency injection now and was able to implement and run unit tests for banme.

We still need to run a redis server to be able to test redistest or any other check relying on redis.

I used dependency injection now and was able to implement and run unit tests for banme. We still need to run a redis server to be able to test redistest or any other check relying on redis.
emacsen commented 2022-10-18 18:49:09 +00:00 (Migrated from gitlab.com)

This is resolved now I believe. Feel free to re-open if not.

This is resolved now I believe. Feel free to re-open if not.
emacsen (Migrated from gitlab.com) closed this issue 2022-10-18 18:49:09 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
babka/activitycolander#20
No description provided.