@@ -10,6 +10,8 @@ const gitFixture = require('../fixtures/git')
10
10
const wibyCommand = path . join ( __dirname , '..' , '..' , 'bin' , 'wiby' )
11
11
const fixturesPath = path . resolve ( path . join ( __dirname , '..' , 'fixtures' ) )
12
12
13
+ const SUCCESS_RESULT_EXIT_CODE = 0
14
+ const FAIL_RESULT_EXIT_CODE = 1
13
15
const PENDING_RESULT_EXIT_CODE = 64
14
16
15
17
tap . test ( 'result command' , async ( tap ) => {
@@ -37,20 +39,64 @@ tap.test('result command', async (tap) => {
37
39
childProcess . execSync ( `${ wibyCommand } result --dependent="https://github.com/wiby-test/fakeRepo"` , {
38
40
env : {
39
41
...process . env ,
40
- NODE_OPTIONS : `-r ${ fixturesPath } /http/result-command-positive.js`
42
+ NODE_OPTIONS : `-r ${ fixturesPath } /http/result-command-positive-pass .js`
41
43
}
42
44
} )
43
45
} catch ( e ) {
44
46
const result = e . output [ 1 ] . toString ( ) . trim ( )
45
47
46
48
tap . equal ( result , expected )
47
- tap . equal ( e . status , PENDING_RESULT_EXIT_CODE )
49
+ tap . equal ( e . status , SUCCESS_RESULT_EXIT_CODE )
48
50
}
49
51
} )
50
52
51
53
tap . test ( 'result command should call result module with all deps from .wiby.json' , async ( tap ) => {
52
54
const expected = fs . readFileSync (
53
- path . join ( __dirname , '..' , 'fixtures' , 'expected-outputs' , 'result' , 'result-output-multiple-dependant.md' ) ,
55
+ path . join ( __dirname , '..' , 'fixtures' , 'expected-outputs' , 'result' , 'result-output-multiple-pass.md' ) ,
56
+ 'utf-8'
57
+ )
58
+ . trim ( )
59
+
60
+ try {
61
+ childProcess . execSync ( `${ wibyCommand } result` , {
62
+ env : {
63
+ ...process . env ,
64
+ NODE_OPTIONS : `-r ${ fixturesPath } /http/result-command-positive-pass.js`
65
+ }
66
+ } )
67
+ } catch ( e ) {
68
+ const result = e . output [ 1 ] . toString ( ) . trim ( )
69
+
70
+ tap . equal ( result , expected )
71
+ tap . equal ( e . status , SUCCESS_RESULT_EXIT_CODE )
72
+ }
73
+ } )
74
+
75
+ tap . test ( 'result command should call result module with all deps from .wiby.json (pending result)' , async ( tap ) => {
76
+ const expected = fs . readFileSync (
77
+ path . join ( __dirname , '..' , 'fixtures' , 'expected-outputs' , 'result' , 'result-output-multiple-pending.md' ) ,
78
+ 'utf-8'
79
+ )
80
+ . trim ( )
81
+
82
+ try {
83
+ childProcess . execSync ( `${ wibyCommand } result` , {
84
+ env : {
85
+ ...process . env ,
86
+ NODE_OPTIONS : `-r ${ fixturesPath } /http/result-command-positive-pending.js`
87
+ }
88
+ } )
89
+ } catch ( e ) {
90
+ const result = e . output [ 1 ] . toString ( ) . trim ( )
91
+
92
+ tap . equal ( result , expected )
93
+ tap . equal ( e . status , PENDING_RESULT_EXIT_CODE )
94
+ }
95
+ } )
96
+
97
+ tap . test ( 'result command should call result module with all deps from .wiby.json (missing branch result)' , async ( tap ) => {
98
+ const expected = fs . readFileSync (
99
+ path . join ( __dirname , '..' , 'fixtures' , 'expected-outputs' , 'result' , 'result-output-missing-branch.md' ) ,
54
100
'utf-8'
55
101
)
56
102
. trim ( )
@@ -59,7 +105,7 @@ tap.test('result command', async (tap) => {
59
105
childProcess . execSync ( `${ wibyCommand } result` , {
60
106
env : {
61
107
...process . env ,
62
- NODE_OPTIONS : `-r ${ fixturesPath } /http/result-command-positive .js`
108
+ NODE_OPTIONS : `-r ${ fixturesPath } /http/result-command-missing-branch .js`
63
109
}
64
110
} )
65
111
} catch ( e ) {
@@ -136,7 +182,7 @@ tap.test('result command', async (tap) => {
136
182
const result = e . output [ 1 ] . toString ( ) . trim ( )
137
183
138
184
tap . equal ( result , expected )
139
- tap . equal ( e . status , 1 )
185
+ tap . equal ( e . status , FAIL_RESULT_EXIT_CODE )
140
186
}
141
187
} )
142
188
} )
0 commit comments