Skip to content

Commit 13cf95d

Browse files
committed
refactor: tests -> move, use Test dir like specified in spago documentation
1 parent 2cc9b29 commit 13cf95d

File tree

7 files changed

+43
-43
lines changed

7 files changed

+43
-43
lines changed

test/Main.purs

-18
This file was deleted.

test/Test/Main.purs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module Test.Main where
2+
3+
import Prelude
4+
5+
import Effect (Effect)
6+
import Test.Node.FS.Sync as Sync
7+
import Test.Node.FS.Streams as Streams
8+
import Test.Node.FS.Aff as Aff
9+
import Test.Node.FS.Async as Async
10+
import Test.Node.FS.OpendirAndDir as OpendirAndDir
11+
12+
main :: Effect Unit
13+
main = do
14+
Sync.main
15+
Async.main
16+
Streams.main
17+
Aff.main
18+
OpendirAndDir.main

test/TestAff.purs renamed to test/Test/Node/FS/Aff.purs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module TestAff where
1+
module Test.Node.FS.Aff where
22

33
import Prelude
44

test/TestAsync.purs renamed to test/Test/Node/FS/Async.purs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module TestAsync where
1+
module Test.Node.FS.Async where
22

33
import Prelude (Unit, show, bind, discard, (<>), ($))
44
import Data.Either (Either(..))
@@ -15,8 +15,8 @@ import Node.Buffer as B
1515
main :: Effect Unit
1616
main = do
1717
let
18-
path1 = FP.concat ([ "test", "TestAsync.purs" ])
19-
path2 = FP.concat ([ "test", "TestAsync.purs.partial" ])
18+
path1 = FP.concat ([ "test", "Test", "Node", "FS", "Async.purs" ])
19+
path2 = FP.concat ([ "test", "Test", "Node", "FS", "Async.purs.partial" ])
2020

2121
buf <- B.create 1000
2222

test/TestDirEntries.purs renamed to test/Test/Node/FS/OpendirAndDir.purs

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module TestDirEntries where
1+
module Test.Node.FS.OpendirAndDir where
22

33
import Prelude
44

@@ -21,7 +21,8 @@ import Node.Path as Path
2121
import Test.Assert (assertEqual)
2222

2323
outerTmpDir :: FilePath
24-
outerTmpDir = "./tmp/dir-entries-test"
24+
outerTmpDir = Path.concat ["tmp", "dir-entries-test"]
25+
-- outerTmpDir = Path.concat [".", "tmp", "dir-entries-test"]
2526

2627
prepare :: Aff Unit
2728
prepare = do
@@ -42,18 +43,18 @@ test1 = do
4243
, expected:
4344
"""[Dirent Dirent {
4445
name: 'dir1',
45-
parentPath: './tmp/dir-entries-test',
46-
path: './tmp/dir-entries-test',
46+
parentPath: 'tmp/dir-entries-test',
47+
path: 'tmp/dir-entries-test',
4748
[Symbol(type)]: 2
4849
},Dirent Dirent {
4950
name: '1.txt',
50-
parentPath: './tmp/dir-entries-test',
51-
path: './tmp/dir-entries-test',
51+
parentPath: 'tmp/dir-entries-test',
52+
path: 'tmp/dir-entries-test',
5253
[Symbol(type)]: 1
5354
},Dirent Dirent {
5455
name: '2.txt',
55-
parentPath: './tmp/dir-entries-test',
56-
path: './tmp/dir-entries-test',
56+
parentPath: 'tmp/dir-entries-test',
57+
path: 'tmp/dir-entries-test',
5758
[Symbol(type)]: 1
5859
},Dirent Dirent {
5960
name: '3.txt',
@@ -78,15 +79,15 @@ test2 = do
7879
dir <- A.opendir' outerTmpDir (opendirOptionsDefault { recursive = false })
7980
read dir >>= \file -> liftEffect $ assertEqual
8081
{ actual: show file
81-
, expected: "(Just Dirent Dirent {\n name: 'dir1',\n parentPath: './tmp/dir-entries-test',\n path: './tmp/dir-entries-test',\n [Symbol(type)]: 2\n})"
82+
, expected: "(Just Dirent Dirent {\n name: 'dir1',\n parentPath: 'tmp/dir-entries-test',\n path: 'tmp/dir-entries-test',\n [Symbol(type)]: 2\n})"
8283
}
8384
read dir >>= \file -> liftEffect $ assertEqual
8485
{ actual: show file
85-
, expected: "(Just Dirent Dirent {\n name: '1.txt',\n parentPath: './tmp/dir-entries-test',\n path: './tmp/dir-entries-test',\n [Symbol(type)]: 1\n})"
86+
, expected: "(Just Dirent Dirent {\n name: '1.txt',\n parentPath: 'tmp/dir-entries-test',\n path: 'tmp/dir-entries-test',\n [Symbol(type)]: 1\n})"
8687
}
8788
read dir >>= \file -> liftEffect $ assertEqual
8889
{ actual: show file
89-
, expected: "(Just Dirent Dirent {\n name: '2.txt',\n parentPath: './tmp/dir-entries-test',\n path: './tmp/dir-entries-test',\n [Symbol(type)]: 1\n})"
90+
, expected: "(Just Dirent Dirent {\n name: '2.txt',\n parentPath: 'tmp/dir-entries-test',\n path: 'tmp/dir-entries-test',\n [Symbol(type)]: 1\n})"
9091
}
9192
read dir >>= \file -> liftEffect $ assertEqual
9293
{ actual: show file

test/Streams.purs renamed to test/Test/Node/FS/Streams.purs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Test.Streams where
1+
module Test.Node.FS.Streams where
22

33
import Prelude
44

@@ -17,13 +17,13 @@ main = do
1717

1818
log "Testing streams"
1919

20-
r <- createReadStream (fp [ "test", "Streams.purs" ])
20+
r <- createReadStream (fp [ "test", "Test", "Node", "FS", "Streams.purs" ])
2121
w <- createWriteStream (fp [ "tmp", "Streams.purs" ])
2222

2323
_ <- Stream.pipe r w
2424

2525
r # on_ Stream.endH do
26-
src <- Sync.readTextFile UTF8 (fp [ "test", "Streams.purs" ])
26+
src <- Sync.readTextFile UTF8 (fp [ "test", "Test", "Node", "FS", "Streams.purs" ])
2727
dst <- Sync.readTextFile UTF8 (fp [ "tmp", "Streams.purs" ])
2828

2929
if src == dst then log "all good"

test/Test.purs renamed to test/Test/Node/FS/Sync.purs

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Test where
1+
module Test.Node.FS.Sync where
22

33
import Prelude
44

@@ -35,10 +35,10 @@ main :: Effect Unit
3535
main = do
3636
let fp = Path.concat
3737

38-
e <- S.exists (fp [ "test", "Test.purs" ])
38+
e <- S.exists (fp [ "test", "Test", "Node", "FS", "Sync.purs" ])
3939
log $ "Test.purs exists? " <> show e
4040

41-
file <- S.readTextFile UTF8 (fp [ "test", "Test.purs" ])
41+
file <- S.readTextFile UTF8 (fp [ "test", "Test", "Node", "FS", "Sync.purs" ])
4242
log "\n\nreadTextFile sync result:"
4343
log $ file
4444

@@ -99,16 +99,16 @@ main = do
9999
log "\n\ntruncate result:"
100100
either (log <<< show) (log <<< show) y
101101

102-
A.readFile (fp [ "test", "Test.purs" ]) $ \mbuf -> do
102+
A.readFile (fp [ "test", "Test", "Node", "FS", "Sync.purs" ]) $ \mbuf -> do
103103
buf <- traverse Buffer.freeze mbuf
104104
log "\n\nreadFile result:"
105105
either (log <<< show) (log <<< show) buf
106106

107-
A.readTextFile UTF8 (fp [ "test", "Test.purs" ]) $ \x -> do
107+
A.readTextFile UTF8 (fp [ "test", "Test", "Node", "FS", "Sync.purs" ]) $ \x -> do
108108
log "\n\nreadTextFile result:"
109109
either (log <<< show) log x
110110

111-
A.stat (fp [ "test", "Test.purs" ]) $ \x -> do
111+
A.stat (fp [ "test", "Test", "Node", "FS", "Sync.purs" ]) $ \x -> do
112112
log "\n\nA.stat:"
113113
case x of
114114
Left err -> log $ "Error:" <> show err
@@ -197,4 +197,3 @@ main = do
197197
case copyErr of
198198
Left _ -> pure unit
199199
Right _ -> throw $ destReadPath <> " already exists, but copying a file to there did not throw an error with COPYFILE_EXCL option"
200-

0 commit comments

Comments
 (0)