Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-dir.lua « tests - github.com/stevedonovan/Penlight.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5ed49350bcd00ff89b157e21a2ebff8dc5686eaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
-- This test file expects to be ran from 'run.lua' in the root Penlight directory.

local dir = require( "pl.dir" )
local file = require( "pl.file" )
local path = require( "pl.path" )
local asserteq = require( "pl.test" ).asserteq
local pretty = require( "pl.pretty" )

local normpath = path.normpath

local expected = {normpath "../docs/function_index.txt"}

local files = dir.getallfiles( normpath "../docs/", "*.txt" )

asserteq( files, expected )

-- Test move files -----------------------------------------

-- Create a dummy file
local fileName = path.tmpname()
file.write( fileName, string.rep( "poot ", 1000 ) )

local newFileName = path.tmpname()
local err, msg = dir.movefile( fileName, newFileName )

-- Make sure the move is successful
assert( err, msg )

-- Check to make sure the original file is gone

asserteq( path.exists( fileName ), false )

-- Check to make sure the new file is there
asserteq (path.exists( newFileName ) , newFileName)

-- Clean up
file.delete( newFileName )