Skip to content

Commit

Permalink
[stdlib] complete tests
Browse files Browse the repository at this point in the history
Signed-off-by: Artemio Garza Reyna <artemiogr97@gmail.com>
  • Loading branch information
artemiogr97 committed Apr 28, 2024
1 parent f3fdb98 commit f2b9e2c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions stdlib/test/os/test_mkdir_and_rmdir.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ fn test_mkdir_mode() raises:
var my_dir_path = cwd_path / "my_dir"
var file_name = my_dir_path / "file.txt"

assert_false(
exists(my_dir_path),
"Unexpected dir " + my_dir_path.__fspath__() + " it should not exist",
)

# creating dir without writing permission
mkdir(my_dir_path, 0o111)

Expand All @@ -88,6 +93,29 @@ fn test_mkdir_mode() raises:
rmdir(my_dir_path)


fn test_rmdir_not_emty() raises:
var cwd_path = Path()
var my_dir_path = cwd_path / "my_dir"
var file_name = my_dir_path / "file.txt"

assert_false(
exists(my_dir_path),
"Unexpected dir " + my_dir_path.__fspath__() + " it should not exist",
)

mkdir(my_dir_path)
with open(file_name, "w"):
pass

with assert_raises(contains="Can not remove directory: "):
rmdir(my_dir_path)

remove(file_name)
rmdir(my_dir_path)
assert_true(exists(my_dir_path), "Failed to remove dir")


fn main() raises:
test_mkdir_and_rmdir()
test_mkdir_mode()
test_rmdir_not_emty()

0 comments on commit f2b9e2c

Please sign in to comment.