aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/vlib/os/inode_test.v
diff options
context:
space:
mode:
authorIndrajith K L2022-12-03 17:00:20 +0530
committerIndrajith K L2022-12-03 17:00:20 +0530
commitf5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch)
tree2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/vlib/os/inode_test.v
downloadcli-tools-windows-master.tar.gz
cli-tools-windows-master.tar.bz2
cli-tools-windows-master.zip
Adds most of the toolsHEADmaster
Diffstat (limited to 'v_windows/v/vlib/os/inode_test.v')
-rw-r--r--v_windows/v/vlib/os/inode_test.v43
1 files changed, 43 insertions, 0 deletions
diff --git a/v_windows/v/vlib/os/inode_test.v b/v_windows/v/vlib/os/inode_test.v
new file mode 100644
index 0000000..f716bc2
--- /dev/null
+++ b/v_windows/v/vlib/os/inode_test.v
@@ -0,0 +1,43 @@
+module os
+
+const (
+ // tfolder will contain all the temporary files/subfolders made by
+ // the different tests. It would be removed in testsuite_end(), so
+ // individual os tests do not need to clean up after themselves.
+ tfolder = join_path(temp_dir(), 'v', 'tests', 'inode_test')
+)
+
+fn testsuite_begin() {
+ eprintln('testsuite_begin, tfolder = $os.tfolder')
+ rmdir_all(os.tfolder) or {}
+ assert !is_dir(os.tfolder)
+ mkdir_all(os.tfolder) or { panic(err) }
+ chdir(os.tfolder) or {}
+ assert is_dir(os.tfolder)
+}
+
+fn testsuite_end() {
+ chdir(wd_at_startup) or {}
+ rmdir_all(os.tfolder) or { panic(err) }
+ assert !is_dir(os.tfolder)
+}
+
+fn test_inode_file_type() {
+ filename := './test1.txt'
+ mut file := open_file(filename, 'w', 0o600) or { return }
+ file.close()
+ mode := inode(filename)
+ rm(filename) or { panic(err) }
+ assert mode.typ == .regular
+}
+
+fn test_inode_file_owner_permission() {
+ filename := './test2.txt'
+ mut file := open_file(filename, 'w', 0o600) or { return }
+ file.close()
+ mode := inode(filename)
+ rm(filename) or {}
+ assert mode.owner.read
+ assert mode.owner.write
+ assert !mode.owner.execute
+}