robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3 4local describe , it , before_each , after_each =t . describe , t . it , t . before_each , t . after_each 5local clear =n . clear 6local command , eq , neq , write_file =n . command , t . eq , t . neq , t . write_file 7local read_file =t . read_file 8local is_os =t . is_os 9 10describe ( ':wshada' , function () 11local shada_file ='wshada_test' 12 13before_each ( function () 14clear { 15args ={ 16'-i' , 17is_os ( 'win' ) and 'nul' or '/dev/null' , 18-- Need 'swapfile' for these tests. 19'--cmd' , 20'set swapfile undodir=. directory=. viewdir=. backupdir=. belloff= noshowcmd noruler' , 21} , 22args_rm ={ '-n' , '-i' , '--cmd' } , 23} 24end ) 25after_each ( function () 26os . remove ( shada_file ) 27end ) 28 29it ( 'creates a shada file' , function () 30-- file should _not_ exist 31eq ( nil , vim . uv . fs_stat ( shada_file )) 32command ( 'wsh! ' .. shada_file ) 33-- file _should_ exist 34neq ( nil , vim . uv . fs_stat ( shada_file )) 35end ) 36 37it ( 'overwrites existing files' , function () 38local text ='wshada test' 39 40-- Create a dummy file 41write_file ( shada_file , text ) 42 43-- sanity check 44eq ( text , read_file ( shada_file )) 45neq ( nil , vim . uv . fs_stat ( shada_file )) 46 47command ( 'wsh! ' .. shada_file ) 48 49-- File should have been overwritten with a shada file. 50local fp =io . open ( shada_file , 'r' ) 51local char1 =fp : read ( 1 ) 52fp : close () 53-- ShaDa file starts with a “header” entry 54assert ( char1 : byte () == 0x01 , shada_file .. ' should be a shada file' ) 55end ) 56end )