@@ -2,7 +2,7 @@ import test from 'tape'
2
2
import sinon from 'sinon'
3
3
import Promise from 'bluebird'
4
4
import runContentfulExport from '../lib/run-contentful-export'
5
-
5
+ import dumpErrorBuffer from '../lib/dump-error-buffer'
6
6
const fullSpaceResponse = {
7
7
'contentTypes' : [ ] ,
8
8
'entries' : [ ] ,
@@ -16,22 +16,40 @@ runContentfulExport.__Rewire__('createClients', createClientsStub)
16
16
const getFullSourceSpaceStub = sinon . stub ( ) . returns ( Promise . resolve ( fullSpaceResponse ) )
17
17
runContentfulExport . __Rewire__ ( 'getFullSourceSpace' , getFullSourceSpaceStub )
18
18
19
+ const getFullSourceSpaceWithErrorStub = sinon . stub ( ) . returns ( Promise . reject ( { request : { uri : 'erroruri' } } ) )
19
20
const fsMock = {
20
21
writeFile : sinon . stub ( ) . returns ( Promise . resolve ( ) )
21
22
}
22
23
runContentfulExport . __Rewire__ ( 'fs' , fsMock )
24
+ dumpErrorBuffer . __Rewire__ ( 'fs' , fsMock )
25
+ const dumpErrorBufferStub = sinon . stub ( )
26
+ runContentfulExport . __Rewire__ ( 'dumpErrorBuffer' , dumpErrorBufferStub )
23
27
24
- test ( 'Runs space sync ' , ( t ) => {
28
+ test ( 'Runs Contentful Export ' , ( t ) => {
25
29
runContentfulExport ( {
26
30
opts : { } ,
27
31
errorLogFile : 'errorlogfile'
28
32
} )
29
33
. then ( ( ) => {
30
34
t . ok ( createClientsStub . called , 'create clients' )
31
35
t . ok ( getFullSourceSpaceStub . called , 'get full space' )
36
+ runContentfulExport . __ResetDependency__ ( 'getFullSourceSpace' )
37
+ t . end ( )
38
+ } )
39
+ } )
32
40
33
- runContentfulExport . __ResetDependency__ ( 'createClients' )
41
+ test ( 'Runs Contentful fails' , ( t ) => {
42
+ runContentfulExport . __Rewire__ ( 'getFullSourceSpace' , getFullSourceSpaceWithErrorStub )
43
+ runContentfulExport ( {
44
+ opts : { } ,
45
+ errorLogFile : 'errorlogfile'
46
+ } )
47
+ . then ( ( ) => { } )
48
+ . catch ( ( ) => {
49
+ t . ok ( dumpErrorBufferStub . called )
34
50
runContentfulExport . __ResetDependency__ ( 'getFullSourceSpace' )
51
+ runContentfulExport . __ResetDependency__ ( 'createClients' )
52
+ runContentfulExport . __ResetDependency__ ( 'dumpErrorBuffer' )
35
53
t . end ( )
36
54
} )
37
55
} )
0 commit comments