aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorScott Prager <splinterofchaos@gmail.com>2015-04-14 15:45:39 -0400
committerScott Prager <splinterofchaos@gmail.com>2015-04-14 15:45:39 -0400
commitb47ea5fcdefb2ce33bae3d61d79310646aa8d1a1 (patch)
treedebc07712054605b63f1867e8b23609a3f6b49ca /test
parentd22f2f94047a5ed1e930ee46d0d2e8d6aacfa104 (diff)
parent9353fcf024e4752c20c59a9c519f080e33cc5df2 (diff)
downloadrneovim-b47ea5fcdefb2ce33bae3d61d79310646aa8d1a1.tar.gz
rneovim-b47ea5fcdefb2ce33bae3d61d79310646aa8d1a1.tar.bz2
rneovim-b47ea5fcdefb2ce33bae3d61d79310646aa8d1a1.zip
Merge pull request #2331 from splinterofchaos/serverlisten
vimL: serverlisten({addr}), list(), and stop({addr})
Diffstat (limited to 'test')
-rw-r--r--test/functional/server/server_spec.lua42
-rw-r--r--test/unit/os/env_spec.lua17
2 files changed, 59 insertions, 0 deletions
diff --git a/test/functional/server/server_spec.lua b/test/functional/server/server_spec.lua
new file mode 100644
index 0000000000..5dd8197d52
--- /dev/null
+++ b/test/functional/server/server_spec.lua
@@ -0,0 +1,42 @@
+
+local helpers = require('test.functional.helpers')
+local nvim, eq, neq, ok, eval
+ = helpers.nvim, helpers.eq, helpers.neq, helpers.ok, helpers.eval
+local clear = helpers.clear
+
+describe('server*() functions', function()
+ before_each(clear)
+
+ it('set $NVIM_LISTEN_ADDRESS on first serverstart()', function()
+ -- Ensure the listen address is unset.
+ nvim('command', 'let $NVIM_LISTEN_ADDRESS = ""')
+ nvim('command', 'let s = serverstart()')
+ eq(1, eval('$NVIM_LISTEN_ADDRESS == s'))
+ nvim('command', 'call serverstop(s)')
+ eq(0, eval('$NVIM_LISTEN_ADDRESS == s'))
+ end)
+
+ it('let the user retrieve the list of servers', function()
+ -- There should already be at least one server.
+ local n = eval('len(serverlist())')
+
+ -- Add a few
+ local servs = {'should-not-exist', 'another-one-that-shouldnt'}
+ for _, s in ipairs(servs) do
+ eq(s, eval('serverstart("'..s..'")'))
+ end
+
+ local new_servs = eval('serverlist()')
+
+ -- Exactly #servs servers should be added.
+ eq(n + #servs, #new_servs)
+ -- The new servers should be at the end of the list.
+ for i = 1, #servs do
+ eq(servs[i], new_servs[i + n])
+ nvim('command', 'call serverstop("'..servs[i]..'")')
+ end
+ -- After calling serverstop() on the new servers, they should no longer be
+ -- in the list.
+ eq(n, eval('len(serverlist())'))
+ end)
+end)
diff --git a/test/unit/os/env_spec.lua b/test/unit/os/env_spec.lua
index 5896f5ddd4..9d936c2564 100644
--- a/test/unit/os/env_spec.lua
+++ b/test/unit/os/env_spec.lua
@@ -3,6 +3,7 @@ local helpers = require('test.unit.helpers')
local cimport = helpers.cimport
local internalize = helpers.internalize
local eq = helpers.eq
+local neq = helpers.neq
local ffi = helpers.ffi
local lib = helpers.lib
local cstr = helpers.cstr
@@ -21,6 +22,10 @@ describe('env function', function()
return env.os_setenv((to_cstr(name)), (to_cstr(value)), override)
end
+ function os_unsetenv(name, value, override)
+ return env.os_unsetenv((to_cstr(name)))
+ end
+
function os_getenv(name)
local rval = env.os_getenv((to_cstr(name)))
if rval ~= NULL then
@@ -68,6 +73,18 @@ describe('env function', function()
end)
end)
+ describe('os_unsetenv', function()
+ it('unsets environment variable', function()
+ local name = 'TEST_UNSETENV'
+ local value = 'TESTVALUE'
+ os_setenv(name, value, 1)
+ os_unsetenv(name)
+ neq(os_getenv(name), value)
+ -- Depending on the platform the var might be unset or set as ''
+ assert.True(os_getenv(name) == nil or os_getenv(name) == '')
+ end)
+ end)
+
describe('os_getenvname_at_index', function()
it('returns names of environment variables', function()
local test_name = 'NEOVIM_UNIT_TEST_GETENVNAME_AT_INDEX_1N'