1
- var proxyquire = require ( 'proxyquire' )
2
1
var test = require ( 'tap' ) . test
3
2
var SRError = require ( '@semantic-release/error' )
4
3
5
- var condition = proxyquire ( './' , {
6
- 'travis-after-all' : function ( cb ) {
7
- cb ( 0 )
8
- }
9
- } )
4
+ var condition = require ( './' )
10
5
11
- test ( 'raise errors in travis environment' , function ( t ) {
12
- t . test ( 'only runs on travis ' , function ( tt ) {
6
+ test ( 'raise errors in codeship environment' , function ( t ) {
7
+ t . test ( 'only runs on codeship ' , function ( tt ) {
13
8
tt . plan ( 2 )
14
9
15
10
condition ( { } , { env : { } } , function ( err ) {
16
11
tt . ok ( err instanceof SRError )
17
- tt . is ( err . code , 'ENOTRAVIS ' )
12
+ tt . is ( err . code , 'ENOCODESHIP ' )
18
13
} )
19
14
} )
20
15
21
16
t . test ( 'not running on pull requests' , function ( tt ) {
22
17
tt . plan ( 2 )
23
18
condition ( { } , {
24
19
env : {
25
- TRAVIS : 'true ' ,
26
- TRAVIS_PULL_REQUEST : '105 '
20
+ CI_NAME : 'codeship ' ,
21
+ CI_PULL_REQUEST : 'true '
27
22
}
28
23
} , function ( err ) {
29
24
tt . ok ( err instanceof SRError )
30
25
tt . is ( err . code , 'EPULLREQUEST' )
31
26
} )
32
27
} )
33
28
34
- t . test ( 'not running on tags' , function ( tt ) {
35
- tt . plan ( 2 )
36
- condition ( { } , {
37
- env : {
38
- TRAVIS : 'true' ,
39
- TRAVIS_PULL_REQUEST : 'false' ,
40
- TRAVIS_TAG : 'v1.0.0'
41
- }
42
- } , function ( err ) {
43
- tt . ok ( err instanceof SRError )
44
- tt . is ( err . code , 'EGITTAG' )
45
- } )
46
- } )
47
-
48
29
t . test ( 'only running on specified branch' , function ( tt ) {
49
30
tt . plan ( 5 )
50
31
51
32
condition ( { } , {
52
33
env : {
53
- TRAVIS : 'true ' ,
54
- TRAVIS_BRANCH : 'master'
34
+ CI_NAME : 'codeship ' ,
35
+ CI_BRANCH : 'master'
55
36
} ,
56
37
options : {
57
38
branch : 'master'
@@ -62,8 +43,8 @@ test('raise errors in travis environment', function (t) {
62
43
63
44
condition ( { } , {
64
45
env : {
65
- TRAVIS : 'true ' ,
66
- TRAVIS_BRANCH : 'notmaster'
46
+ CI_NAME : 'codeship ' ,
47
+ CI_BRANCH : 'notmaster'
67
48
} ,
68
49
options : {
69
50
branch : 'master'
@@ -75,8 +56,8 @@ test('raise errors in travis environment', function (t) {
75
56
76
57
condition ( { } , {
77
58
env : {
78
- TRAVIS : 'true ' ,
79
- TRAVIS_BRANCH : 'master'
59
+ CI_NAME : 'codeship ' ,
60
+ CI_BRANCH : 'master'
80
61
} ,
81
62
options : {
82
63
branch : 'foo'
@@ -87,93 +68,5 @@ test('raise errors in travis environment', function (t) {
87
68
} )
88
69
} )
89
70
90
- t . test ( 'supports travis-after-all' , function ( tt ) {
91
- tt . plan ( 8 )
92
-
93
- proxyquire ( './' , {
94
- 'travis-after-all' : function ( cb ) {
95
- cb ( 0 )
96
- }
97
- } ) ( { } , {
98
- env : {
99
- TRAVIS : 'true' ,
100
- TRAVIS_BRANCH : 'master'
101
- } ,
102
- options : {
103
- branch : 'master'
104
- }
105
- } , function ( err ) {
106
- tt . is ( err , null )
107
- } )
108
-
109
- proxyquire ( './' , {
110
- 'travis-after-all' : function ( cb ) {
111
- cb ( 2 )
112
- }
113
- } ) ( { } , {
114
- env : {
115
- TRAVIS : 'true' ,
116
- TRAVIS_BRANCH : 'master'
117
- } ,
118
- options : {
119
- branch : 'master'
120
- }
121
- } , function ( err ) {
122
- tt . ok ( err instanceof SRError )
123
- tt . is ( err . code , 'ENOBUILDLEADER' )
124
- } )
125
-
126
- proxyquire ( './' , {
127
- 'travis-after-all' : function ( cb ) {
128
- cb ( 1 )
129
- }
130
- } ) ( { } , {
131
- env : {
132
- TRAVIS : 'true' ,
133
- TRAVIS_BRANCH : 'master'
134
- } ,
135
- options : {
136
- branch : 'master'
137
- }
138
- } , function ( err ) {
139
- tt . ok ( err instanceof SRError )
140
- tt . is ( err . code , 'EOTHERSFAILED' )
141
- } )
142
-
143
- proxyquire ( './' , {
144
- 'travis-after-all' : function ( cb ) {
145
- cb ( 'weird?' )
146
- }
147
- } ) ( { } , {
148
- env : {
149
- TRAVIS : 'true' ,
150
- TRAVIS_BRANCH : 'master'
151
- } ,
152
- options : {
153
- branch : 'master'
154
- }
155
- } , function ( err ) {
156
- tt . ok ( err instanceof SRError )
157
- tt . is ( err . code , 'ETAAFAIL' )
158
- } )
159
-
160
- var error = { }
161
- proxyquire ( './' , {
162
- 'travis-after-all' : function ( cb ) {
163
- cb ( null , error )
164
- }
165
- } ) ( { } , {
166
- env : {
167
- TRAVIS : 'true' ,
168
- TRAVIS_BRANCH : 'master'
169
- } ,
170
- options : {
171
- branch : 'master'
172
- }
173
- } , function ( err ) {
174
- tt . is ( err , error )
175
- } )
176
- } )
177
-
178
71
t . end ( )
179
72
} )
0 commit comments