match lowercase true/false
This commit is contained in:
parent
decb62d15a
commit
4e64ddd798
|
@ -61,11 +61,11 @@ function _M.getenv(name, parse)
|
||||||
|
|
||||||
-- try to parse as boolean
|
-- try to parse as boolean
|
||||||
if parse == "boolean" then
|
if parse == "boolean" then
|
||||||
if value == "true" or value == "1" then
|
if string.lower(value) == "true" or value == "1" then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if value == "false" or value == "0" then
|
if string.lower(value) == "false" or value == "0" then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -135,6 +135,12 @@ describe("getenv", function()
|
||||||
assert.is_true(utils.getenv("foo", "boolean"))
|
assert.is_true(utils.getenv("foo", "boolean"))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("should parse 'True' string as true", function()
|
||||||
|
os.getenv.on_call_with("foo").returns("True")
|
||||||
|
|
||||||
|
assert.is_true(utils.getenv("foo", "boolean"))
|
||||||
|
end)
|
||||||
|
|
||||||
it("should parse '1' string as true", function()
|
it("should parse '1' string as true", function()
|
||||||
os.getenv.on_call_with("foo").returns("1")
|
os.getenv.on_call_with("foo").returns("1")
|
||||||
|
|
||||||
|
@ -147,6 +153,12 @@ describe("getenv", function()
|
||||||
assert.is_false(utils.getenv("foo", "boolean"))
|
assert.is_false(utils.getenv("foo", "boolean"))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("should parse 'False' string as false", function()
|
||||||
|
os.getenv.on_call_with("foo").returns("False")
|
||||||
|
|
||||||
|
assert.is_false(utils.getenv("foo", "boolean"))
|
||||||
|
end)
|
||||||
|
|
||||||
it("should parse '0' string as false", function()
|
it("should parse '0' string as false", function()
|
||||||
os.getenv.on_call_with("foo").returns("0")
|
os.getenv.on_call_with("foo").returns("0")
|
||||||
|
|
||||||
|
|
Reference in New Issue