$ ./test-run.sh
=== gsearch-cli Test Runner ===
✓ Test database already exists: test.db
Step 2: Displaying database statistics...
Command: go run ./cmd/gsearch-cli -db test.db -stats
Explanation: Shows database metadata including number of folders, files, and index flags
Database Statistics:
Folders: 5
Files: 5
Total entries: 10
Index flags: 13
Sorted arrays: 0
Step 3: Running search queries...
--- Search 1: Find files/folders containing 'test' ---
Command: go run ./cmd/gsearch-cli -db test.db -q test
Explanation: Searches for entries with 'test' in the name (case-insensitive by default)
Found 2 result(s):
📄 /home/user/test.txt (1.0 KB)
📄 /Documents/test.go (8.0 KB)
--- Search 2: Find files only containing 'test' ---
Command: go run ./cmd/gsearch-cli -db test.db -q test -files
Explanation: Same search but filters to show only files, excluding folders
Found 2 result(s):
📄 /home/user/test.txt (1.0 KB)
📄 /Documents/test.go (8.0 KB)
--- Search 3: Find folders containing 'doc' ---
Command: go run ./cmd/gsearch-cli -db test.db -q doc -folders
Explanation: Searches for folders with 'doc' in the name, excluding files
Found 1 result(s):
📁 /Documents
--- Search 4: Search in full path for 'home' ---
Command: go run ./cmd/gsearch-cli -db test.db -path home
Explanation: Searches in the full path (not just name) for entries containing 'home'
Found 4 result(s):
📁 /home
📁 /home/user
📄 /home/user/test.txt (1.0 KB)
📄 /home/user/readme.txt (2.0 KB)
--- Search 5: Case-sensitive search for 'Test' ---
Command: go run ./cmd/gsearch-cli -db test.db -q Test -case
Explanation: Case-sensitive search that will only match 'Test' (capital T), not 'test'
No results found.
--- Search 6: Limit results to 1 ---
Command: go run ./cmd/gsearch-cli -db test.db -q test -max 1
Explanation: Limits the search results to maximum 1 result
Found 1 result(s):
📄 /home/user/test.txt (1.0 KB)
--- Search 7: Wildcard - Find all .txt files ---
Command: go run ./cmd/gsearch-cli -db test.db -q '*.txt'
Explanation: Wildcard pattern * matches any sequence. *.txt finds all files ending with .txt
Found 2 result(s):
📄 /home/user/test.txt (1.0 KB)
📄 /home/user/readme.txt (2.0 KB)
--- Search 8: Wildcard - Find files starting with 'test' ---
Command: go run ./cmd/gsearch-cli -db test.db -q 'test*'
Explanation: Wildcard pattern test* matches files starting with 'test' followed by any characters
Found 2 result(s):
📄 /home/user/test.txt (1.0 KB)
📄 /Documents/test.go (8.0 KB)
--- Search 9: Wildcard - Find files with single char + .go ---
Command: go run ./cmd/gsearch-cli -db test.db -q '?.go'
Explanation: Wildcard pattern ? matches a single character. ?.go finds files like 'a.go', 'b.go'
No results found.
--- Search 10: Wildcard path search - Find all in /home/* ---
Command: go run ./cmd/gsearch-cli -db test.db -path '/home/*'
Explanation: Wildcard patterns work in path searches too. /home/* finds all entries under /home
Found 3 result(s):
📁 /home/user
📄 /home/user/test.txt (1.0 KB)
📄 /home/user/readme.txt (2.0 KB)
--- Search 11: JSON output format ---
Command: go run ./cmd/gsearch-cli -db test.db -q test -output json
Explanation: Output results in JSON format with structured fields: name, path, type, size, mtime
[
{
"name": "test.txt",
"path": "/home/user/test.txt",
"type": "file",
"size": 1024,
"mtime": "2026-01-03T18:36:00-05:00",
"mtime_ts": 1767483360
},
{
"name": "test.go",
"path": "/Documents/test.go",
"type": "file",
"size": 8192,
"mtime": "2026-01-03T18:36:00-05:00",
"mtime_ts": 1767483360
}
]
--- Search 12: CSV output format ---
Command: go run ./cmd/gsearch-cli -db test.db -q test -output csv
Explanation: Output results in CSV format with header row, suitable for spreadsheet import
name,path,type,size,mtime
test.txt,/home/user/test.txt,file,1024,2026-01-03T18:36:00-05:00
test.go,/Documents/test.go,file,8192,2026-01-03T18:36:00-05:00
--- Search 13: Sort results by size ---
Command: go run ./cmd/gsearch-cli -db test.db -q '*' -sort size
Explanation: Sort all results by file size (ascending). Folders are sorted by name when sorting by size
Found 10 result(s):
📁 /
📁 /Documents
📁 /Downloads
📁 /home
📁 /home/user
📄 /home/user/test.txt (1.0 KB)
📄 /home/user/readme.txt (2.0 KB)
📄 /Documents/document.pdf (4.0 KB)
📄 /Documents/test.go (8.0 KB)
📄 /Downloads/file.zip (16.0 KB)
--- Search 14: Sort results by modification time ---
Command: go run ./cmd/gsearch-cli -db test.db -q '*' -sort mtime
Explanation: Sort results by modification time (oldest first)
Found 10 result(s):
📁 /
📁 /home
📁 /home/user
📁 /Documents
📁 /Downloads
📄 /home/user/test.txt (1.0 KB)
📄 /home/user/readme.txt (2.0 KB)
📄 /Documents/document.pdf (4.0 KB)
📄 /Documents/test.go (8.0 KB)
📄 /Downloads/file.zip (16.0 KB)
--- Search 15: Combined options - JSON output with size sorting ---
Command: go run ./cmd/gsearch-cli -db test.db -q '*.txt' -sort size -output json
Explanation: Combine multiple options: wildcard search, sorting, and JSON output
[
{
"name": "test.txt",
"path": "/home/user/test.txt",
"type": "file",
"size": 1024,
"mtime": "2026-01-03T18:36:00-05:00",
"mtime_ts": 1767483360
},
{
"name": "readme.txt",
"path": "/home/user/readme.txt",
"type": "file",
"size": 2048,
"mtime": "2026-01-03T18:36:00-05:00",
"mtime_ts": 1767483360
}
]
=== Test run completed ===