@@ -16,7 +16,8 @@ before(function(done) {
1616
1717
1818//file to upload
19- var imageFile = path . join ( __dirname , 'logo.png' ) ;
19+ var testFilePath1 = path . join ( __dirname , 'logo.png' ) ;
20+ var testFilePath2 = path . join ( __dirname , 'github.png' ) ;
2021
2122describe ( 'test form io' , function ( ) {
2223 var accessKey = proc . env . QINIU_ACCESS_KEY ;
@@ -61,16 +62,14 @@ describe('test form io', function() {
6162 describe ( 'test form io#putStreamWithoutKey' , function ( ) {
6263 it ( 'test form io#putStreamWithoutKey' , function ( done ) {
6364 var key = null ;
64- var rs = fs . createReadStream ( imageFile ) ;
65+ var rs = fs . createReadStream ( testFilePath1 ) ;
6566 formUploader . putStream ( uploadToken , key , rs , putExtra ,
6667 function ( respErr ,
6768 respBody , respInfo ) {
6869 //console.log(respBody);
6970 should . not . exist ( respErr ) ;
7071 respBody . should . have . keys ( 'key' , 'hash' ) ;
71- if ( ! keysToDelete . includes ( respBody . key ) ) {
72- keysToDelete . push ( respBody . key ) ;
73- }
72+ keysToDelete . push ( respBody . key ) ;
7473 done ( ) ;
7574 } ) ;
7675 } ) ;
@@ -79,16 +78,14 @@ describe('test form io', function() {
7978 describe ( 'test form io#putStream' , function ( ) {
8079 it ( 'test form io#putStream' , function ( done ) {
8180 var key = 'io_putStream_test' + Math . random ( 1000 ) ;
82- var rs = fs . createReadStream ( imageFile ) ;
81+ var rs = fs . createReadStream ( testFilePath1 ) ;
8382 formUploader . putStream ( uploadToken , key , rs , putExtra ,
8483 function ( respErr ,
8584 respBody , respInfo ) {
8685 //console.log(respBody);
8786 should . not . exist ( respErr ) ;
8887 respBody . should . have . keys ( 'key' , 'hash' ) ;
89- if ( ! keysToDelete . includes ( respBody . key ) ) {
90- keysToDelete . push ( respBody . key ) ;
91- }
88+ keysToDelete . push ( respBody . key ) ;
9289 done ( ) ;
9390 } ) ;
9491 } ) ;
@@ -103,9 +100,7 @@ describe('test form io', function() {
103100 //console.log(respBody);
104101 should . not . exist ( respErr ) ;
105102 respBody . should . have . keys ( 'key' , 'hash' ) ;
106- if ( ! keysToDelete . includes ( respBody . key ) ) {
107- keysToDelete . push ( respBody . key ) ;
108- }
103+ keysToDelete . push ( respBody . key ) ;
109104 done ( ) ;
110105 } ) ;
111106 } ) ;
@@ -120,9 +115,7 @@ describe('test form io', function() {
120115 //console.log(respBody);
121116 should . not . exist ( respErr ) ;
122117 respBody . should . have . keys ( 'key' , 'hash' ) ;
123- if ( ! keysToDelete . includes ( respBody . key ) ) {
124- keysToDelete . push ( respBody . key ) ;
125- }
118+ keysToDelete . push ( respBody . key ) ;
126119 done ( ) ;
127120 } ) ;
128121 } ) ;
@@ -131,34 +124,31 @@ describe('test form io', function() {
131124 describe ( 'test form io#putFile' , function ( ) {
132125 it ( 'test form io#putFile' , function ( done ) {
133126 var key = 'io_putFile_test' + Math . random ( 1000 ) ;
134- formUploader . putFile ( uploadToken , key , imageFile , putExtra ,
127+ formUploader . putFile ( uploadToken , key , testFilePath2 ,
128+ putExtra ,
135129 function (
136130 respErr ,
137131 respBody , respInfo ) {
138132 //console.log(respBody);
139133 should . not . exist ( respErr ) ;
140134 respBody . should . have . keys ( 'key' , 'hash' ) ;
141- if ( ! keysToDelete . includes ( respBody . key ) ) {
142- keysToDelete . push ( respBody . key ) ;
143- }
135+ keysToDelete . push ( respBody . key ) ;
144136 done ( ) ;
145137 } ) ;
146138 } ) ;
147139 } ) ;
148140
149141 describe ( 'test form io#putFileWithoutKey' , function ( ) {
150142 it ( 'test form io#putFileWithoutKey' , function ( done ) {
151- formUploader . putFileWithoutKey ( uploadToken , imageFile ,
143+ formUploader . putFileWithoutKey ( uploadToken , testFilePath2 ,
152144 putExtra ,
153145 function (
154146 respErr ,
155147 respBody , respInfo ) {
156148 //console.log(respBody);
157149 should . not . exist ( respErr ) ;
158150 respBody . should . have . keys ( 'key' , 'hash' ) ;
159- if ( ! keysToDelete . includes ( respBody . key ) ) {
160- keysToDelete . push ( respBody . key ) ;
161- }
151+ keysToDelete . push ( respBody . key ) ;
162152 done ( ) ;
163153 } ) ;
164154 } ) ;
0 commit comments