diff options
author | Scott Prager <splinterofchaos@gmail.com> | 2015-04-02 11:49:22 -0400 |
---|---|---|
committer | Scott Prager <splinterofchaos@gmail.com> | 2015-04-14 15:31:04 -0400 |
commit | 9353fcf024e4752c20c59a9c519f080e33cc5df2 (patch) | |
tree | 352211cc9f5396c6af04da51c5edfb3d879f283c /test/functional/server/server_spec.lua | |
parent | 296719428a5adc7c4f00a7f1778771c5ec9af9d0 (diff) | |
download | rneovim-9353fcf024e4752c20c59a9c519f080e33cc5df2.tar.gz rneovim-9353fcf024e4752c20c59a9c519f080e33cc5df2.tar.bz2 rneovim-9353fcf024e4752c20c59a9c519f080e33cc5df2.zip |
server: add unit tests
Diffstat (limited to 'test/functional/server/server_spec.lua')
-rw-r--r-- | test/functional/server/server_spec.lua | 42 |
1 files changed, 42 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) |