@@ -41,6 +41,12 @@ const baseFiles = {
41
41
size : 1258000 ,
42
42
type : 'file' ,
43
43
path : '1.2MiB.txt'
44
+ } ,
45
+ 'small.txt' : {
46
+ cid : 'QmZMb7HWpbevpcdhbUV1ZZgdji8vh5uQ13KxczChGrK9Rd' ,
47
+ size : 15 ,
48
+ type : 'file' ,
49
+ path : 'small.txt'
44
50
}
45
51
}
46
52
@@ -53,6 +59,12 @@ const strategyBaseFiles = {
53
59
}
54
60
} ) ,
55
61
trickle : extend ( { } , baseFiles , {
62
+ '200Bytes.txt' : {
63
+ cid : 'QmY8bwnoKAKvJ8qtyPhWNxSS6sxiGVTJ9VpdQffs2KB5pE' ,
64
+ size : 200 ,
65
+ type : 'file' ,
66
+ path : '200Bytes.txt'
67
+ } ,
56
68
'1.2MiB.txt' : {
57
69
cid : 'QmfAxsHrpaLLuhbqqbo9KQyvQNawMnVSwutYoJed75pnco' ,
58
70
type : 'file'
@@ -62,8 +74,8 @@ const strategyBaseFiles = {
62
74
63
75
const strategies = [
64
76
'flat' ,
65
- 'balanced'
66
- // 'trickle'
77
+ 'balanced' ,
78
+ 'trickle'
67
79
]
68
80
69
81
const strategyOverrides = {
@@ -95,28 +107,52 @@ const strategyOverrides = {
95
107
} ,
96
108
trickle : {
97
109
'foo-big' : {
98
- cid : 'QmPh6KSS7ghTqzgWhaoCiLoHFPF7HGqUxx7q9vcM5HUN4U ' ,
110
+ cid : 'QmaKbhFRy9kcCbcwrLsqYHWMiY44BDYkqTCMpAxDdd2du2 ' ,
99
111
path : 'foo-big' ,
100
112
size : 1334657 ,
101
113
type : 'directory'
102
114
} ,
103
115
pim : {
104
- cid : 'QmPAn3G2x2nrq4A1fu2XUpwWtpqG4D1YXFDrU615NHvJbr ' ,
116
+ cid : 'QmbWGdnua4YuYpWJb7fE25PRbW9GbKKLqq9Ucmnsg2gxnt ' ,
105
117
path : 'pim' ,
106
118
size : 1334923 ,
107
119
type : 'directory'
108
120
} ,
109
121
'pam/pum' : {
110
- cid : 'QmPAn3G2x2nrq4A1fu2XUpwWtpqG4D1YXFDrU615NHvJbr ' ,
122
+ cid : 'QmbWGdnua4YuYpWJb7fE25PRbW9GbKKLqq9Ucmnsg2gxnt ' ,
111
123
path : 'pam/pum' ,
112
124
size : 1334923 ,
113
125
type : 'directory'
114
126
} ,
115
127
pam : {
116
- cid : 'QmZTJah1xpG9X33ZsPtDEi1tYSHGDqQMRHsGV5xKzAR2j4 ' ,
128
+ cid : 'QmSuh47G9Qm3PFv1zziojtHxqCjuurSdtWAzxLxoKJPq2U ' ,
117
129
path : 'pam' ,
118
130
size : 2669627 ,
119
131
type : 'directory'
132
+ } ,
133
+ '200Bytes.txt with raw leaves' : {
134
+ cid : 'QmagyRwMfYhczYNv5SvcJc8xxXjZQBTTHS2jEqNMva2mYT' ,
135
+ size : 200 ,
136
+ path : '200Bytes.txt' ,
137
+ type : 'file'
138
+ } ,
139
+ 'foo/bar' : {
140
+ cid : 'QmTGMxKPzSGNBDp6jhTwnZxGW6w1S9ciyycRJ4b2qcQaHK' ,
141
+ size : 0 ,
142
+ path : 'foo/bar' ,
143
+ type : 'directory'
144
+ } ,
145
+ foo : {
146
+ cid : 'Qme4A8fZmwfZESappfPcxSMTZVACiEzhHKtYRMuM1hbkDp' ,
147
+ size : 0 ,
148
+ path : 'foo' ,
149
+ type : 'directory'
150
+ } ,
151
+ 'small.txt' : {
152
+ cid : 'QmXmZ3qT328JxWtQXqrmvma2FmPp7tMdNiSuYvVJ5QRhKs' ,
153
+ size : 15 ,
154
+ type : 'file' ,
155
+ path : 'small.txt'
120
156
}
121
157
}
122
158
}
@@ -301,7 +337,7 @@ strategies.forEach((strategy) => {
301
337
302
338
expect ( files . length ) . to . eql ( 1 )
303
339
304
- // always yield empty node
340
+ // always yield empty file node
305
341
expect ( files [ 0 ] . cid . toBaseEncodedString ( ) ) . to . eql ( 'QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH' )
306
342
} )
307
343
@@ -379,12 +415,14 @@ strategies.forEach((strategy) => {
379
415
} )
380
416
381
417
it ( 'small file as string (smaller than a chunk)' , async ( ) => {
382
- const file = await first ( importer ( [ {
383
- path : '200Bytes .txt' ,
418
+ const files = await all ( importer ( [ {
419
+ path : 'small .txt' ,
384
420
content : 'this is a file\n'
385
421
} ] , ipld , options ) )
386
422
387
- expect ( file . cid . toBaseEncodedString ( ) ) . to . equal ( 'QmZMb7HWpbevpcdhbUV1ZZgdji8vh5uQ13KxczChGrK9Rd' )
423
+ expectFiles ( files , [
424
+ 'small.txt'
425
+ ] )
388
426
} )
389
427
390
428
it ( 'small file (smaller than a chunk) with raw leaves' , async ( ) => {
0 commit comments