1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 15:04:42 +00:00

optimize code structure and reduce duplication

This commit is contained in:
Tw93
2025-12-02 15:24:19 +08:00
parent 2ad69b3845
commit bb50a345b6
21 changed files with 421 additions and 409 deletions

View File

@@ -179,12 +179,11 @@ EOF
[ "$status" -eq 0 ]
}
@test "_opt_get_dir_size_kb returns zero for missing directory" {
@test "get_path_size_kb returns zero for missing directory" {
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc << 'EOF'
set -euo pipefail
source "$PROJECT_ROOT/lib/core/common.sh"
source "$PROJECT_ROOT/lib/optimize/tasks.sh"
size=$(_opt_get_dir_size_kb "/nonexistent/path")
size=$(get_path_size_kb "/nonexistent/path")
echo "$size"
EOF
@@ -192,15 +191,14 @@ EOF
[ "$output" = "0" ]
}
@test "_opt_get_dir_size_kb calculates directory size" {
@test "get_path_size_kb calculates directory size" {
mkdir -p "$HOME/test_size"
dd if=/dev/zero of="$HOME/test_size/file.dat" bs=1024 count=10 2>/dev/null
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc << 'EOF'
set -euo pipefail
source "$PROJECT_ROOT/lib/core/common.sh"
source "$PROJECT_ROOT/lib/optimize/tasks.sh"
size=$(_opt_get_dir_size_kb "$HOME/test_size")
size=$(get_path_size_kb "$HOME/test_size")
echo "$size"
EOF