@@ -28,7 +28,9 @@ describe('touch', () => {
28
28
}
29
29
30
30
const path = '/foo'
31
- const mtime = new Date ( 100000 )
31
+ const mtime = {
32
+ secs : 1000
33
+ }
32
34
let ipfs
33
35
34
36
beforeEach ( ( ) => {
@@ -40,7 +42,7 @@ describe('touch', () => {
40
42
} )
41
43
42
44
it ( 'should update the mtime for a file' , async ( ) => {
43
- await cli ( `files touch -m ${ mtime . getTime ( ) / 1000 } ${ path } ` , { ipfs } )
45
+ await cli ( `files touch -m ${ mtime . secs } ${ path } ` , { ipfs } )
44
46
45
47
expect ( ipfs . files . touch . callCount ) . to . equal ( 1 )
46
48
expect ( ipfs . files . touch . getCall ( 0 ) . args ) . to . deep . equal ( [
@@ -52,7 +54,7 @@ describe('touch', () => {
52
54
} )
53
55
54
56
it ( 'should update the mtime without flushing' , async ( ) => {
55
- await cli ( `files touch -m ${ mtime . getTime ( ) / 1000 } --flush false ${ path } ` , { ipfs } )
57
+ await cli ( `files touch -m ${ mtime . secs } --flush false ${ path } ` , { ipfs } )
56
58
57
59
expect ( ipfs . files . touch . callCount ) . to . equal ( 1 )
58
60
expect ( ipfs . files . touch . getCall ( 0 ) . args ) . to . deep . equal ( [
@@ -65,7 +67,7 @@ describe('touch', () => {
65
67
} )
66
68
67
69
it ( 'should update the mtime without flushing (short option)' , async ( ) => {
68
- await cli ( `files touch -m ${ mtime . getTime ( ) / 1000 } -f false ${ path } ` , { ipfs } )
70
+ await cli ( `files touch -m ${ mtime . secs } -f false ${ path } ` , { ipfs } )
69
71
70
72
expect ( ipfs . files . touch . callCount ) . to . equal ( 1 )
71
73
expect ( ipfs . files . touch . getCall ( 0 ) . args ) . to . deep . equal ( [
@@ -78,7 +80,7 @@ describe('touch', () => {
78
80
} )
79
81
80
82
it ( 'should update the mtime with a different hash algorithm' , async ( ) => {
81
- await cli ( `files touch -m ${ mtime . getTime ( ) / 1000 } --hash-alg sha3-256 ${ path } ` , { ipfs } )
83
+ await cli ( `files touch -m ${ mtime . secs } --hash-alg sha3-256 ${ path } ` , { ipfs } )
82
84
83
85
expect ( ipfs . files . touch . callCount ) . to . equal ( 1 )
84
86
expect ( ipfs . files . touch . getCall ( 0 ) . args ) . to . deep . equal ( [
@@ -91,7 +93,7 @@ describe('touch', () => {
91
93
} )
92
94
93
95
it ( 'should update the mtime with a different hash algorithm (short option)' , async ( ) => {
94
- await cli ( `files touch -m ${ mtime . getTime ( ) / 1000 } -h sha3-256 ${ path } ` , { ipfs } )
96
+ await cli ( `files touch -m ${ mtime . secs } -h sha3-256 ${ path } ` , { ipfs } )
95
97
96
98
expect ( ipfs . files . touch . callCount ) . to . equal ( 1 )
97
99
expect ( ipfs . files . touch . getCall ( 0 ) . args ) . to . deep . equal ( [
@@ -104,7 +106,7 @@ describe('touch', () => {
104
106
} )
105
107
106
108
it ( 'should update the mtime with a shard split threshold' , async ( ) => {
107
- await cli ( `files touch -m ${ mtime . getTime ( ) / 1000 } --shard-split-threshold 10 ${ path } ` , { ipfs } )
109
+ await cli ( `files touch -m ${ mtime . secs } --shard-split-threshold 10 ${ path } ` , { ipfs } )
108
110
109
111
expect ( ipfs . files . touch . callCount ) . to . equal ( 1 )
110
112
expect ( ipfs . files . touch . getCall ( 0 ) . args ) . to . deep . equal ( [
@@ -115,4 +117,19 @@ describe('touch', () => {
115
117
} )
116
118
] )
117
119
} )
120
+
121
+ it ( 'should update the mtime and nsecs' , async ( ) => {
122
+ await cli ( `files touch -m 5 --mtime-nsecs 10 ${ path } ` , { ipfs } )
123
+
124
+ expect ( ipfs . files . touch . callCount ) . to . equal ( 1 )
125
+ expect ( ipfs . files . touch . getCall ( 0 ) . args ) . to . deep . equal ( [
126
+ path ,
127
+ defaultOptions ( {
128
+ mtime : {
129
+ secs : 5 ,
130
+ nsecs : 10
131
+ }
132
+ } )
133
+ ] )
134
+ } )
118
135
} )
0 commit comments