@@ -129,10 +129,10 @@ describe('test start fop', function () {
129129
130130 it ( `test pfop with upload; ${ msg } ` , function ( ) {
131131 const formUploader = new qiniu . form_up . FormUploader ( config ) ;
132- const key = 'qiniu -pfop- upload-file' ;
132+ const key = 'test -pfop/ upload-file' ;
133133 const persistentKey = [
134- 'qiniu -pfop-by-upload' ,
135- 'persistentType ' ,
134+ 'test-pfop/test -pfop-by-upload' ,
135+ 'type ' ,
136136 persistentType
137137 ] . join ( '_' ) ;
138138
@@ -179,4 +179,87 @@ describe('test start fop', function () {
179179 } ) ;
180180 } ) ;
181181 } ) ;
182+
183+ it ( 'test pfop by templateID with api' , function ( ) {
184+ const srcKey = 'qiniu.mp4' ;
185+ const srcBucket = bucketName ;
186+
187+ const templateID = 'test-workflow' ;
188+ const operationManager = new qiniu . fop . OperationManager ( mac , config ) ;
189+
190+ new Promise ( ( resolve , reject ) => {
191+ operationManager . pfop (
192+ srcBucket ,
193+ srcKey ,
194+ null ,
195+ null ,
196+ { workflowTemplateID : templateID } ,
197+ function ( err , respBody , respInfo ) {
198+ if ( err ) {
199+ reject ( err ) ;
200+ return ;
201+ }
202+ resolve ( { data : respBody , resp : respInfo } ) ;
203+ }
204+ ) ;
205+ } )
206+ . then ( ( { data } ) => {
207+ data . should . have . keys ( 'persistentId' ) ;
208+ return new Promise ( ( resolve , reject ) => {
209+ operationManager . prefop (
210+ data . persistentId ,
211+ function ( err , respBody , respInfo ) {
212+ if ( err ) {
213+ reject ( err ) ;
214+ return ;
215+ }
216+ resolve ( { data : respBody , resp : respInfo } ) ;
217+ }
218+ ) ;
219+ } ) ;
220+ } )
221+ . then ( ( { data } ) => {
222+ data . should . have . keys (
223+ 'creationDate' ,
224+ 'taskFrom'
225+ ) ;
226+ } ) ;
227+ } ) ;
228+
229+ it ( 'test pfop by templateID with upload' , function ( ) {
230+ const formUploader = new qiniu . form_up . FormUploader ( config ) ;
231+ const key = 'qiniu-pfop-tplid-upload-file' ;
232+ const templateID = 'test-workflow' ;
233+ const options = {
234+ scope : bucketName ,
235+ persistentWorkflowTemplateID : templateID
236+ } ;
237+ const putPolicy = new qiniu . rs . PutPolicy ( options ) ;
238+ const uploadToken = putPolicy . uploadToken ( mac ) ;
239+ const putExtra = new qiniu . form_up . PutExtra ( ) ;
240+
241+ return formUploader . put ( uploadToken , key , testFilePath , putExtra )
242+ . then ( ( { data } ) => {
243+ data . should . have . keys ( 'key' , 'persistentId' ) ;
244+ return new Promise ( ( resolve , reject ) => {
245+ new qiniu . fop . OperationManager ( mac , config )
246+ . prefop (
247+ data . persistentId ,
248+ function ( err , respBody , respInfo ) {
249+ if ( err ) {
250+ reject ( err ) ;
251+ return ;
252+ }
253+ resolve ( { data : respBody , resp : respInfo } ) ;
254+ }
255+ ) ;
256+ } ) ;
257+ } )
258+ . then ( ( { data } ) => {
259+ data . should . have . keys (
260+ 'creationDate' ,
261+ 'taskFrom'
262+ ) ;
263+ } ) ;
264+ } ) ;
182265} ) ;
0 commit comments