Selaa lähdekoodia

#8 Add test cases for large file and memory leaking

Ben Hsieh 8 vuotta sitten
vanhempi
commit
32a265ae81
2 muutettua tiedostoa jossa 47 lisäystä ja 2 poistoa
  1. 27
    0
      test/test-0.5.x.js
  2. 20
    2
      test/test-init.js

+ 27
- 0
test/test-0.5.x.js Näytä tiedosto

@@ -182,6 +182,33 @@ describe('Upload and download at the same time', (report, done) => {
182 182
 
183 183
 })
184 184
 
185
+RNTest.config({
186
+  group : '0.5.x',
187
+  run : true,
188
+  expand : false,
189
+  timeout : 30000,
190
+})('Upload and download large file', (report, done) => {
191
+  let filename = '22mb-dummy-' + Date.now()
192
+  RNFetchBlob.config({
193
+    fileCache : true
194
+  })
195
+  .fetch('GET', `${TEST_SERVER_URL}/public/22mb-dummy`)
196
+  .then((res) => {
197
+    return RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
198
+      Authorization : `Bearer ${DROPBOX_TOKEN}`,
199
+      'Dropbox-API-Arg': '{\"path\": \"/rn-upload/'+filename+'\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}',
200
+      'Content-Type' : 'application/octet-stream',
201
+    }, RNFetchBlob.wrap(res.path()))
202
+  })
203
+  .then((res) => {
204
+    report(<Assert
205
+      key="upload should success withou crashing app"
206
+      expect={filename}
207
+      actual={res.json().name}/>)
208
+    done()
209
+  })
210
+})
211
+
185 212
 describe('Session create mechanism test', (report, done) => {
186 213
   let sessionName = 'foo-' + Date.now()
187 214
   testSessionName = sessionName

+ 20
- 2
test/test-init.js Näytä tiedosto

@@ -50,8 +50,26 @@ describe('GET image from server', (report, done) => {
50 50
     })
51 51
 })
52 52
 
53
+// // Only use when doing memory leaking test 
54
+// RNTest.config({
55
+//   timeout : 900000000
56
+// })('Memory leaking test', (report, done) => {
57
+//   let promises = []
58
+//   for(let i = 0 ; i < 2000; i++) {
59
+//     promises.push(RNFetchBlob
60
+//       .fetch('GET', `${TEST_SERVER_URL}/public/github.png`, {
61
+//         Authorization : 'Bearer abde123eqweje'
62
+//       })
63
+//     )
64
+//   }
65
+//   Promise.all(promises).then(() => {
66
+//     report(<Assert key="test finished" expect={true} actual={true}/>)
67
+//     done()
68
+//   })
69
+// })
70
+
53 71
 
54 72
 require('./test-0.1.x-0.4.x')
55 73
 require('./test-0.5.x')
56
-// require('./test-fs')
57
-// require('./test-android')
74
+require('./test-fs')
75
+require('./test-android')