summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorSimon Ruderich <simon@ruderich.org>2016-09-17 19:10:03 +0200
committerSimon Ruderich <simon@ruderich.org>2016-09-17 19:13:30 +0200
commit4414dafd5e59096b10b4b371430c9502f354394f (patch)
treee01734318d4caa50958c5cd8dd2382fddf1229c5 /tests
parentf4f8827c0633678ef5828d3b36a1ed645744a7fd (diff)
downloadNim-4414dafd5e59096b10b4b371430c9502f354394f.tar.gz
tests: add more tests for getFileInfo()
Diffstat (limited to 'tests')
-rw-r--r--tests/stdlib/tgetfileinfo.nim32
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/stdlib/tgetfileinfo.nim b/tests/stdlib/tgetfileinfo.nim
index 8a0538a5f..780853afc 100644
--- a/tests/stdlib/tgetfileinfo.nim
+++ b/tests/stdlib/tgetfileinfo.nim
@@ -1,5 +1,5 @@
 discard """
-  output: ""
+  output: "pcDir\npcFile\npcLinkToDir\npcLinkToFile\n"
 """
 
 import os, strutils
@@ -93,4 +93,34 @@ proc testGetFileInfo =
       discard
       #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()