diff options
author | Stefan Hoffmann <stefan991@gmail.com> | 2014-03-16 15:01:22 +0100 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-04-03 10:30:03 -0300 |
commit | 071d28076f4ee057764359999cf2fabc75e99314 (patch) | |
tree | 7303724b94d7b70d60aeb2f370736ce2f6d4714f /test/unit | |
parent | 4a138137f78907703aa9215b45f46b8f37d84ae5 (diff) | |
download | rneovim-071d28076f4ee057764359999cf2fabc75e99314.tar.gz rneovim-071d28076f4ee057764359999cf2fabc75e99314.tar.bz2 rneovim-071d28076f4ee057764359999cf2fabc75e99314.zip |
move check_file_readonly() into /src/os/fs.c and rename it
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/os/fs.moon | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/unit/os/fs.moon b/test/unit/os/fs.moon index 44dd3a123e..82414186d9 100644 --- a/test/unit/os/fs.moon +++ b/test/unit/os/fs.moon @@ -19,6 +19,7 @@ int os_can_exe(char_u *name); int32_t os_getperm(char_u *name); int os_setperm(char_u *name, long perm); int os_file_exists(const char_u *name); +int os_file_is_readonly(char *fname); ]] -- import constants parsed by ffi @@ -282,6 +283,9 @@ describe 'fs function', -> os_setperm = (filename, perm) -> fs.os_setperm (to_cstr filename), perm + os_file_is_readonly = (filename) -> + fs.os_file_is_readonly (to_cstr filename) + bit_set = (number, check_bit) -> if 0 == (bit.band number, check_bit) then false else true @@ -322,6 +326,20 @@ describe 'fs function', -> perm = ffi.C.kS_IXUSR eq FAIL, (os_setperm 'non-existing-file', perm) + describe 'os_file_is_readonly', -> + it 'returns TRUE if the file is readonly', -> + perm = os_getperm 'unit-test-directory/test.file' + perm_orig = perm + perm = unset_bit perm, ffi.C.kS_IWUSR + perm = unset_bit perm, ffi.C.kS_IWGRP + perm = unset_bit perm, ffi.C.kS_IWOTH + eq OK, (os_setperm 'unit-test-directory/test.file', perm) + eq TRUE, os_file_is_readonly 'unit-test-directory/test.file' + eq OK, (os_setperm 'unit-test-directory/test.file', perm_orig) + + it 'returns FALSE if the file is writable', -> + eq FALSE, os_file_is_readonly 'unit-test-directory/test.file' + describe 'os_file_exists', -> os_file_exists = (filename) -> fs.os_file_exists (to_cstr filename) |