This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -161,7 +161,8 @@ exports.add = {
161161 'only-hash' : Joi . boolean ( ) ,
162162 pin : Joi . boolean ( ) . default ( true ) ,
163163 'wrap-with-directory' : Joi . boolean ( ) ,
164- chunker : Joi . string ( )
164+ chunker : Joi . string ( ) ,
165+ trickle : Joi . boolean ( )
165166 } )
166167 // TODO: Necessary until validate "recursive", "stream-channels" etc.
167168 . options ( { allowUnknown : true } )
@@ -218,7 +219,8 @@ exports.add = {
218219 hashAlg : request . query . hash ,
219220 wrapWithDirectory : request . query [ 'wrap-with-directory' ] ,
220221 pin : request . query . pin ,
221- chunker : request . query . chunker
222+ chunker : request . query . chunker ,
223+ strategy : request . query . trickle ? 'trickle' : 'balanced'
222224 }
223225
224226 const aborter = abortable ( )
Original file line number Diff line number Diff line change @@ -76,6 +76,40 @@ module.exports = (http) => {
7676 expect ( res . statusCode ) . to . equal ( 200 )
7777 expect ( multibase . isEncoded ( JSON . parse ( res . result ) . Hash ) ) . to . deep . equal ( 'base64' )
7878 } )
79+
80+ it ( 'should add data using the trickle importer' , async ( ) => {
81+ const form = new FormData ( )
82+ form . append ( 'data' , Buffer . from ( 'TEST\n' ) )
83+ const headers = form . getHeaders ( )
84+
85+ const payload = await streamToPromise ( form )
86+ const res = await api . inject ( {
87+ method : 'POST' ,
88+ url : '/api/v0/add?trickle=true&pin=false' ,
89+ headers,
90+ payload
91+ } )
92+
93+ expect ( res . statusCode ) . to . equal ( 200 )
94+ expect ( JSON . parse ( res . result ) . Hash ) . to . equal ( 'QmRJTAvvv1UNgCXxK9grf6u2pCT2ZQ2wCwsojpC1sTjkp9' )
95+ } )
96+
97+ it ( 'should add data using the balanced importer' , async ( ) => {
98+ const form = new FormData ( )
99+ form . append ( 'data' , Buffer . from ( 'TEST\n' ) )
100+ const headers = form . getHeaders ( )
101+
102+ const payload = await streamToPromise ( form )
103+ const res = await api . inject ( {
104+ method : 'POST' ,
105+ url : '/api/v0/add?pin=false' ,
106+ headers,
107+ payload
108+ } )
109+
110+ expect ( res . statusCode ) . to . equal ( 200 )
111+ expect ( JSON . parse ( res . result ) . Hash ) . to . equal ( 'Qmdudp5XvJr7KrqK6fQ7m2ACStoRxuwfovNHnY6dAAeUis' )
112+ } )
79113 } )
80114
81115 describe ( '/cat' , ( ) => {
You can’t perform that action at this time.
0 commit comments