Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow accessing private mod variables #66

Open
S-S-X opened this issue Dec 3, 2021 · 1 comment
Open

Allow accessing private mod variables #66

S-S-X opened this issue Dec 3, 2021 · 1 comment
Labels
enhancement New feature or request question Further information is requested

Comments

@S-S-X
Copy link
Owner

S-S-X commented Dec 3, 2021

This should allow retrieving local variables and functions for validation and unit tests.

For example could be mineunit:get_local("init.lua", "secretdata") to get local secretdata = "internal stuff" defined in mod init.lua.

Internal functions could be tested with

it("returns Hello World", function()
  local fn = mineunit:get_local("init.lua", "hello")
  assert.is_function(fn)
  assert.equals("Hello World", fn("World"))
end)

When mod init.lua contains

local function hello(msg)
  return "Hello " .. msg
end
@S-S-X S-S-X added the enhancement New feature or request label Dec 3, 2021
@S-S-X S-S-X added the question Further information is requested label Apr 3, 2022
@S-S-X
Copy link
Owner Author

S-S-X commented Apr 3, 2022

This might not be that good idea after all, sure it would allow testing internal API / functions / variables but is harder to keep track of, might be confusing (when tests fail even while API is completely fine) and possibly encourages worse tests and worse API design.

Also I'm not sure if there's any legitimate uses for this feature.

@S-S-X S-S-X added this to Mineunit Jan 11, 2024
@S-S-X S-S-X moved this to In review in Mineunit Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
Status: In review
Development

No branches or pull requests

1 participant