2016-04-15 05:57:29 -07:00
|
|
|
-- Specs for :write
|
|
|
|
|
2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2016-04-15 05:57:29 -07:00
|
|
|
local eq, eval, clear, write_file, execute, source =
|
|
|
|
helpers.eq, helpers.eval, helpers.clear, helpers.write_file,
|
|
|
|
helpers.execute, helpers.source
|
|
|
|
|
|
|
|
describe(':write', function()
|
|
|
|
it('&backupcopy=auto preserves symlinks', function()
|
|
|
|
clear('set backupcopy=auto')
|
|
|
|
os.remove('test_bkc_file.txt')
|
|
|
|
os.remove('test_bkc_link.txt')
|
|
|
|
write_file('test_bkc_file.txt', 'content0')
|
|
|
|
execute("silent !ln -s test_bkc_file.txt test_bkc_link.txt")
|
|
|
|
source([[
|
|
|
|
edit test_bkc_link.txt
|
|
|
|
call setline(1, ['content1'])
|
|
|
|
write
|
|
|
|
]])
|
|
|
|
eq(eval("['content1']"), eval("readfile('test_bkc_file.txt')"))
|
|
|
|
eq(eval("['content1']"), eval("readfile('test_bkc_link.txt')"))
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('&backupcopy=no replaces symlink with new file', function()
|
|
|
|
clear('set backupcopy=no')
|
|
|
|
os.remove('test_bkc_file.txt')
|
|
|
|
os.remove('test_bkc_link.txt')
|
|
|
|
write_file('test_bkc_file.txt', 'content0')
|
|
|
|
execute("silent !ln -s test_bkc_file.txt test_bkc_link.txt")
|
|
|
|
source([[
|
|
|
|
edit test_bkc_link.txt
|
|
|
|
call setline(1, ['content1'])
|
|
|
|
write
|
|
|
|
]])
|
|
|
|
eq(eval("['content0']"), eval("readfile('test_bkc_file.txt')"))
|
|
|
|
eq(eval("['content1']"), eval("readfile('test_bkc_link.txt')"))
|
|
|
|
end)
|
|
|
|
end)
|