File tree 2 files changed +24
-21
lines changed
2 files changed +24
-21
lines changed Original file line number Diff line number Diff line change @@ -200,19 +200,10 @@ Transaction.prototype.commit = function(callback) {
200
200
this . request_ ( protoOpts , reqOpts , function ( err , resp ) {
201
201
if ( err ) {
202
202
// Rollback automatically for the user.
203
- self . rollback ( function ( err ) {
204
- if ( err ) {
205
- err . message = [
206
- 'The commit was not successful and the transaction could not be' ,
207
- 'rolled back. You may want to try calling transaction.rollback().' ,
208
- '\n' ,
209
- '\n' ,
210
- err . message
211
- ] . join ( '' ) ;
212
- }
213
-
214
- // Provide the response items from the failed commit to the user. A
215
- // successful rollback should be transparent.
203
+ self . rollback ( function ( ) {
204
+ // Provide the response items from the failed commit to the user. Even
205
+ // a failed rollback should be transparent.
206
+ // RE: https://github.com/GoogleCloudPlatform/gcloud-node/pull/1369#discussion_r66833976
216
207
callback ( err , resp ) ;
217
208
} ) ;
218
209
return ;
Original file line number Diff line number Diff line change @@ -161,15 +161,27 @@ describe('Transaction', function() {
161
161
transaction . commit ( done ) ;
162
162
} ) ;
163
163
164
- it ( 'should pass error to callback ', function ( done ) {
164
+ describe ( 'errors ', function ( ) {
165
165
var error = new Error ( 'Error.' ) ;
166
- transaction . request_ = function ( protoOpts , reqOpts , callback ) {
167
- callback = callback || reqOpts ;
168
- callback ( error ) ;
169
- } ;
170
- transaction . commit ( function ( err ) {
171
- assert . deepEqual ( err , error ) ;
172
- done ( ) ;
166
+ var apiResponse = { } ;
167
+
168
+ beforeEach ( function ( ) {
169
+ transaction . rollback = function ( callback ) {
170
+ callback ( ) ;
171
+ } ;
172
+
173
+ transaction . request_ = function ( protoOpts , reqOpts , callback ) {
174
+ callback = callback || reqOpts ;
175
+ callback ( error , apiResponse ) ;
176
+ } ;
177
+ } ) ;
178
+
179
+ it ( 'should pass the error to the callback' , function ( done ) {
180
+ transaction . commit ( function ( err , resp ) {
181
+ assert . strictEqual ( err , error ) ;
182
+ assert . strictEqual ( resp , apiResponse ) ;
183
+ done ( ) ;
184
+ } ) ;
173
185
} ) ;
174
186
} ) ;
175
187
You can’t perform that action at this time.
0 commit comments