tests: add more tests for getFileInfo()
This commit is contained in:
parent
f4f8827c06
commit
4414dafd5e
1 changed files with 31 additions and 1 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
output: ""
|
output: "pcDir\npcFile\npcLinkToDir\npcLinkToFile\n"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os, strutils
|
import os, strutils
|
||||||
|
|
@ -93,4 +93,34 @@ proc testGetFileInfo =
|
||||||
discard
|
discard
|
||||||
#echo("Handle : Invalid File : Success")
|
#echo("Handle : Invalid File : Success")
|
||||||
|
|
||||||
|
# Test kind for files, directories and symlinks.
|
||||||
|
block:
|
||||||
|
let
|
||||||
|
tmp = getTempDir()
|
||||||
|
dirPath = tmp / "test-dir"
|
||||||
|
filePath = tmp / "test-file"
|
||||||
|
linkDirPath = tmp / "test-link-dir"
|
||||||
|
linkFilePath = tmp / "test-link-file"
|
||||||
|
|
||||||
|
createDir(dirPath)
|
||||||
|
writeFile(filePath, "")
|
||||||
|
createSymlink(dirPath, linkDirPath)
|
||||||
|
createSymlink(filePath, linkFilePath)
|
||||||
|
|
||||||
|
let
|
||||||
|
dirInfo = getFileInfo(dirPath)
|
||||||
|
fileInfo = getFileInfo(filePath)
|
||||||
|
linkDirInfo = getFileInfo(linkDirPath, followSymlink = false)
|
||||||
|
linkFileInfo = getFileInfo(linkFilePath, followSymlink = false)
|
||||||
|
|
||||||
|
echo dirInfo.kind
|
||||||
|
echo fileInfo.kind
|
||||||
|
echo linkDirInfo.kind
|
||||||
|
echo linkFileInfo.kind
|
||||||
|
|
||||||
|
removeDir(dirPath)
|
||||||
|
removeFile(filePath)
|
||||||
|
removeFile(linkDirPath)
|
||||||
|
removeFile(linkFilePath)
|
||||||
|
|
||||||
testGetFileInfo()
|
testGetFileInfo()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue