summaryrefslogtreecommitdiff
path: root/test/tclient
diff options
context:
space:
mode:
Diffstat (limited to 'test/tclient')
-rw-r--r--test/tclient/init.lua1
-rw-r--r--test/tclient/tests/library-ignore-limit.lua4
-rw-r--r--test/tclient/tests/multi-workspace.lua80
-rw-r--r--test/tclient/tests/single-mode.lua1
4 files changed, 84 insertions, 2 deletions
diff --git a/test/tclient/init.lua b/test/tclient/init.lua
index 8e7df570..872c34a4 100644
--- a/test/tclient/init.lua
+++ b/test/tclient/init.lua
@@ -1,2 +1,3 @@
require 'tclient.tests.single-mode'
require 'tclient.tests.library-ignore-limit'
+require 'tclient.tests.multi-workspace'
diff --git a/test/tclient/tests/library-ignore-limit.lua b/test/tclient/tests/library-ignore-limit.lua
index baf42978..dcf8717a 100644
--- a/test/tclient/tests/library-ignore-limit.lua
+++ b/test/tclient/tests/library-ignore-limit.lua
@@ -21,7 +21,9 @@ lclient():start(function (client)
end)
fs.create_directories(fs.path(libraryPath))
- util.saveFile(largeFilePath, string.rep('--this is a large file\n', 100000))
+ if not fs.exists(fs.path(largeFilePath)) then
+ util.saveFile(largeFilePath, string.rep('--this is a large file\n', 100000))
+ end
client:initialize()
diff --git a/test/tclient/tests/multi-workspace.lua b/test/tclient/tests/multi-workspace.lua
new file mode 100644
index 00000000..99b7f122
--- /dev/null
+++ b/test/tclient/tests/multi-workspace.lua
@@ -0,0 +1,80 @@
+local lclient = require 'tclient.lclient'
+local fs = require 'bee.filesystem'
+local util = require 'utility'
+local furi = require 'file-uri'
+local ws = require 'workspace'
+local files = require 'files'
+
+local rootPath = LOGPATH .. '/multi-workspace'
+local rootUri = furi.encode(rootPath)
+
+for _, name in ipairs { 'ws1', 'ws2', 'share', 'lb1', 'lb2' } do
+ fs.create_directories(fs.path(rootPath .. '/' .. name))
+ util.saveFile(rootPath .. '/' .. name .. '/test.lua', '')
+end
+
+---@async
+lclient():start(function (client)
+ client:registerFakers()
+
+ client:register('workspace/configuration', function (params)
+ local uri = params.items[1].scopeUri
+ if uri == rootUri .. '/ws1' then
+ return {
+ {
+ ['workspace.library'] = {
+ rootPath .. '/share',
+ rootPath .. '/lb1',
+ }
+ }
+ }
+ end
+ if uri == rootUri .. '/ws2' then
+ return {
+ {
+ ['workspace.library'] = {
+ rootPath .. '/share',
+ rootPath .. '/lb2',
+ }
+ }
+ }
+ end
+ return {}
+ end)
+
+ client:initialize {
+ rootPath = rootPath,
+ rootUri = rootUri,
+ workspaceFolders = {
+ {
+ name = 'ws1',
+ uri = rootUri .. '/ws1',
+ },
+ {
+ name = 'ws2',
+ uri = rootUri .. '/ws2',
+ },
+ }
+ }
+
+ ws.awaitReady(rootUri .. '/ws1')
+ ws.awaitReady(rootUri .. '/ws2')
+
+ assert(files.getState(rootUri .. '/ws1/test.lua') ~= nil)
+ assert(files.getState(rootUri .. '/ws2/test.lua') ~= nil)
+ assert(files.getState(rootUri .. '/share/test.lua') ~= nil)
+ assert(files.getState(rootUri .. '/lb1/test.lua') ~= nil)
+ assert(files.getState(rootUri .. '/lb2/test.lua') ~= nil)
+
+ assert(ws.getScope(rootUri .. '/ws1/test.lua').uri == rootUri .. '/ws1')
+ assert(ws.getScope(rootUri .. '/ws2/test.lua').uri == rootUri .. '/ws2')
+ assert(ws.getScope(rootUri .. '/share/test.lua').uri == rootUri .. '/ws1')
+ assert(ws.getScope(rootUri .. '/lb1/test.lua').uri == rootUri .. '/ws1')
+ assert(ws.getScope(rootUri .. '/lb2/test.lua').uri == rootUri .. '/ws2')
+
+ assert(files.isLibrary(rootUri .. '/ws1/test.lua') == false)
+ assert(files.isLibrary(rootUri .. '/ws2/test.lua') == false)
+ assert(files.isLibrary(rootUri .. '/share/test.lua') == true)
+ assert(files.isLibrary(rootUri .. '/lb1/test.lua') == true)
+ assert(files.isLibrary(rootUri .. '/lb2/test.lua') == true)
+end)
diff --git a/test/tclient/tests/single-mode.lua b/test/tclient/tests/single-mode.lua
index d26eb98a..0a7f85ff 100644
--- a/test/tclient/tests/single-mode.lua
+++ b/test/tclient/tests/single-mode.lua
@@ -1,4 +1,3 @@
-local await = require 'await'
local lclient = require 'tclient.lclient'
local ws = require 'workspace'
local util = require 'utility'