2017-04-07 19:46:33 +02:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2018-01-24 18:01:14 +08:00
|
|
|
local eq = helpers.eq
|
2017-04-07 19:46:33 +02:00
|
|
|
local ok = helpers.ok
|
|
|
|
|
local call = helpers.call
|
|
|
|
|
local clear = helpers.clear
|
2018-01-24 18:01:14 +08:00
|
|
|
local iswin = helpers.iswin
|
2017-04-07 19:46:33 +02:00
|
|
|
|
|
|
|
|
describe('hostname()', function()
|
|
|
|
|
before_each(clear)
|
|
|
|
|
|
|
|
|
|
it('returns hostname string', function()
|
|
|
|
|
local actual = call('hostname')
|
2017-07-02 00:48:17 +08:00
|
|
|
ok(string.len(actual) > 0)
|
2017-04-07 19:46:33 +02:00
|
|
|
if call('executable', 'hostname') == 1 then
|
|
|
|
|
local expected = string.gsub(call('system', 'hostname'), '[\n\r]', '')
|
2018-01-24 18:01:14 +08:00
|
|
|
eq((iswin() and expected:upper() or expected),
|
|
|
|
|
(iswin() and actual:upper() or actual))
|
2017-04-07 19:46:33 +02:00
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end)
|