11require (" plenary.async" ).tests .add_to_env ()
22local TmpDir = require (" tests.tmpdir" )
33local files = require (" oil.adapters.files" )
4+ local fs = require (" oil.fs" )
45local test_util = require (" tests.test_util" )
56
67a .describe (" files adapter" , function ()
@@ -15,13 +16,25 @@ a.describe("files adapter", function()
1516 test_util .reset_editor ()
1617 end )
1718
18- a .it (" tmpdir creates files and asserts they exist " , function ()
19- tmpdir :create ({ " a.txt" , " foo/b.txt " , " foo/c.txt " , " bar/ " })
19+ a .it (" tmpdir creates file and asserts it exists " , function ()
20+ tmpdir :create ({ " a.txt" })
2021 tmpdir :assert_fs ({
2122 [" a.txt" ] = " a.txt" ,
23+ })
24+ end )
25+
26+ a .it (" tmpdir creates directory and asserts it exists" , function ()
27+ tmpdir :create ({ " bar/" })
28+ tmpdir :assert_fs ({
29+ [" bar/" ] = true ,
30+ })
31+ end )
32+
33+ a .it (" tmpdir creates directory and files and asserts they exist" , function ()
34+ tmpdir :create ({ " foo/b.txt" , " foo/c.txt" })
35+ tmpdir :assert_fs ({
2236 [" foo/b.txt" ] = " foo/b.txt" ,
2337 [" foo/c.txt" ] = " foo/c.txt" ,
24- [" bar/" ] = true ,
2538 })
2639 end )
2740
@@ -147,16 +160,32 @@ a.describe("files adapter", function()
147160 })
148161 end )
149162
150- a .it (" Editing a new oil://path/ creates an oil buffer" , function ()
163+ a .it (" Editing a new unnormalized oil://path/ creates an oil buffer" , function ()
151164 local tmpdir_url = " oil://" .. vim .fn .fnamemodify (tmpdir .path , " :p" ) .. " /"
152165 vim .cmd .edit ({ args = { tmpdir_url } })
153166 test_util .wait_oil_ready ()
154- local new_url = " oil://" .. vim .fn .fnamemodify (tmpdir .path , " :p" ) .. " newdir"
155- vim .cmd .edit ({ args = { new_url } })
167+ local unnormalized_url = " oil://" .. vim .fn .fnamemodify (tmpdir .path , " :p" ) .. " newdir"
168+ local normalized_url = " oil://"
169+ .. fs .os_to_posix_path (vim .fn .fnamemodify (tmpdir .path , " :p" ))
170+ .. " newdir/"
171+ vim .cmd .edit ({ args = { unnormalized_url } })
156172 test_util .wait_oil_ready ()
157173 assert .equals (" oil" , vim .bo .filetype )
158174 -- The normalization will add a '/'
159- assert .equals (new_url .. " /" , vim .api .nvim_buf_get_name (0 ))
175+ assert .equals (normalized_url , vim .api .nvim_buf_get_name (0 ))
176+ end )
177+
178+ a .it (" Editing a new normalized oil://path/ creates an oil buffer" , function ()
179+ local tmpdir_url = " oil://" .. vim .fn .fnamemodify (tmpdir .path , " :p" ) .. " /"
180+ vim .cmd .edit ({ args = { tmpdir_url } })
181+ test_util .wait_oil_ready ()
182+ local new_url = " oil://"
183+ .. fs .os_to_posix_path (vim .fn .fnamemodify (tmpdir .path , " :p" ))
184+ .. " newdir/"
185+ vim .cmd .edit ({ args = { new_url } })
186+ test_util .wait_oil_ready ()
187+ assert .equals (" oil" , vim .bo .filetype )
188+ assert .equals (new_url , vim .api .nvim_buf_get_name (0 ))
160189 end )
161190
162191 a .it (" Editing a new oil://file.rb creates a normal buffer" , function ()
0 commit comments