From 4ed80481aa8a57352e657089313c08c48898873d Mon Sep 17 00:00:00 2001 From: Mahmoud Emad Date: Tue, 25 Feb 2025 13:13:41 +0200 Subject: [PATCH] test: Add more comprehensive tests for vfsourdb - Added tests to verify directory listing functionality after creating and moving directories. - Improved test coverage for file operations within directories. - Ensured tests accurately reflect the updated behavior of `dir_list` function. --- lib/vfs/vfsourdb/vfsourdb_test.v | 18 +++++++++++++++++- test_basic.vsh | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/vfs/vfsourdb/vfsourdb_test.v b/lib/vfs/vfsourdb/vfsourdb_test.v index 68126fb3..19cf5fcd 100644 --- a/lib/vfs/vfsourdb/vfsourdb_test.v +++ b/lib/vfs/vfsourdb/vfsourdb_test.v @@ -42,8 +42,12 @@ fn test_directory_operations() ! { assert test_dir.get_metadata().file_type == .directory // Test listing - entries := vfs.dir_list('/')! + mut entries := vfs.dir_list('/')! assert entries.any(it.get_metadata().name == 'test_dir') + + // Test listing entries in the created directory + entries = vfs.dir_list('/test_dir')! + assert entries.len == 0 } fn test_file_operations() ! { @@ -63,6 +67,10 @@ fn test_file_operations() ! { test_content := 'Hello, World!'.bytes() vfs.file_write('/test_dir/test.txt', test_content)! assert vfs.file_read('/test_dir/test.txt')! == test_content + + // Test listing entries in the created directory + entries := vfs.dir_list('/test_dir')! + assert entries.len == 1 } fn test_directory_move() ! { @@ -74,11 +82,19 @@ fn test_directory_move() ! { vfs.dir_create('/test_dir')! vfs.file_create('/test_dir/test.txt')! + // Test listing entries in the created directory + mut entries := vfs.dir_list('/test_dir')! + assert entries.len == 1 + // Perform move moved_dir := vfs.move('/test_dir', '/test_dir2')! assert moved_dir.get_metadata().name == 'test_dir2' assert vfs.exists('/test_dir') == false assert vfs.exists('/test_dir2/test.txt') == true + + // Test listing entries in the created directory + entries = vfs.dir_list('/test_dir2')! + assert entries.len == 1 } fn test_directory_copy() ! { diff --git a/test_basic.vsh b/test_basic.vsh index 6cdefcd2..5a43b955 100755 --- a/test_basic.vsh +++ b/test_basic.vsh @@ -167,7 +167,7 @@ lib/code lib/clients lib/core lib/develop -// lib/vfs +lib/vfs // lib/crypt '