@@ -19,7 +19,11 @@ module.exports = (common, options) => {
1919
2020 let ipfs
2121
22- before ( async ( ) => { ipfs = ( await common . spawn ( ) ) . api } )
22+ before ( async ( ) => {
23+ ipfs = ( await common . spawn ( {
24+ args : common . opts . type === 'go' ? [ ] : [ '--enable-sharding-experiment' ]
25+ } ) ) . api
26+ } )
2327 before ( async ( ) => { await ipfs . add ( fixtures . smallFile . data ) } )
2428
2529 after ( ( ) => common . clean ( ) )
@@ -50,6 +54,41 @@ module.exports = (common, options) => {
5054 expect ( stat . sizeLocal ) . to . be . undefined ( )
5155 } )
5256
57+ it ( 'should stat file with mode' , async function ( ) {
58+ const testDir = `/test-${ hat ( ) } `
59+
60+ await ipfs . files . mkdir ( testDir , { parents : true } )
61+ await ipfs . files . write ( `${ testDir } /b` , Buffer . from ( 'Hello, world!' ) , { create : true } )
62+
63+ const stat = await ipfs . files . stat ( `${ testDir } /b` )
64+
65+ expect ( stat ) . to . include ( {
66+ mode : 0o644
67+ } )
68+ } )
69+
70+ it ( 'should stat file with mtime' , async function ( ) {
71+ const testDir = `/test-${ hat ( ) } `
72+
73+ await ipfs . files . mkdir ( testDir , { parents : true } )
74+ await ipfs . files . write ( `${ testDir } /b` , Buffer . from ( 'Hello, world!' ) , {
75+ create : true ,
76+ mtime : {
77+ secs : 5 ,
78+ nsecs : 0
79+ }
80+ } )
81+
82+ const stat = await ipfs . files . stat ( `${ testDir } /b` )
83+
84+ expect ( stat ) . to . deep . include ( {
85+ mtime : {
86+ secs : 5 ,
87+ nsecs : 0
88+ }
89+ } )
90+ } )
91+
5392 it ( 'should stat dir' , async function ( ) {
5493 const testDir = `/test-${ hat ( ) } `
5594
@@ -68,6 +107,81 @@ module.exports = (common, options) => {
68107 expect ( stat . sizeLocal ) . to . be . undefined ( )
69108 } )
70109
110+ it ( 'should stat dir with mode' , async function ( ) {
111+ const testDir = `/test-${ hat ( ) } `
112+
113+ await ipfs . files . mkdir ( testDir , { parents : true } )
114+ const stat = await ipfs . files . stat ( testDir )
115+
116+ expect ( stat ) . to . include ( {
117+ mode : 0o755
118+ } )
119+ } )
120+
121+ it ( 'should stat dir with mtime' , async function ( ) {
122+ const testDir = `/test-${ hat ( ) } `
123+
124+ await ipfs . files . mkdir ( testDir , {
125+ parents : true ,
126+ mtime : {
127+ secs : 5 ,
128+ nsecs : 0
129+ }
130+ } )
131+
132+ const stat = await ipfs . files . stat ( testDir )
133+
134+ expect ( stat ) . to . deep . include ( {
135+ mtime : {
136+ secs : 5 ,
137+ nsecs : 0
138+ }
139+ } )
140+ } )
141+
142+ it ( 'should stat sharded dir with mode' , async function ( ) {
143+ const testDir = `/test-${ hat ( ) } `
144+
145+ await ipfs . files . mkdir ( testDir , { parents : true } )
146+ await ipfs . files . write ( `${ testDir } /a` , Buffer . from ( 'Hello, world!' ) , {
147+ create : true ,
148+ shardSplitThreshold : 0
149+ } )
150+
151+ const stat = await ipfs . files . stat ( testDir )
152+
153+ expect ( stat ) . to . have . property ( 'type' , 'hamt-sharded-directory' )
154+ expect ( stat ) . to . include ( {
155+ mode : 0o755
156+ } )
157+ } )
158+
159+ it ( 'should stat sharded dir with mtime' , async function ( ) {
160+ const testDir = `/test-${ hat ( ) } `
161+
162+ await ipfs . files . mkdir ( testDir , {
163+ parents : true ,
164+ mtime : {
165+ secs : 5 ,
166+ nsecs : 0
167+ }
168+ } )
169+ await ipfs . files . write ( `${ testDir } /a` , Buffer . from ( 'Hello, world!' ) , {
170+ create : true ,
171+ shardSplitThreshold : 0
172+ } )
173+
174+ const stat = await ipfs . files . stat ( testDir )
175+
176+ expect ( stat ) . to . have . property ( 'type' , 'hamt-sharded-directory' )
177+ expect ( stat ) . to . deep . include ( {
178+ mtime : {
179+ secs : 5 ,
180+ nsecs : 0
181+ }
182+ } )
183+ } )
184+
71185 // TODO enable this test when this feature gets released on go-ipfs
72186 it . skip ( 'should stat withLocal file' , async function ( ) {
73187 const stat = await ipfs . files . stat ( '/test/b' , { withLocal : true } )
0 commit comments