TritonDataCenter / node-manta

Node.js SDK for Manta
75 stars 54 forks source link

return response argument from client.commitUpload #323

Closed jmwski closed 7 years ago

jmwski commented 7 years ago

In https://devhub.joyent.com/jira/browse/MANTA-3368 we'd like to add a test to muskie which inspects the headers returned with and mpu-commit operation. To facilitate this, we'd like to return the res object to the callback passed to client.commitUpload.

jmwski commented 7 years ago

To continue this discussion, do we have a reason for not explicitly returning this response argument to callbacks passed to other node-manta api functions? It seems doing this might be useful for testing if we add headers to certain responses that we then want to use in tests in the future.

jmwski commented 7 years ago

The change is here: https://cr.joyent.us/#/c/2448/. Manual testing included successfully running make prepush. Additionally, I modified a copy of mmpu in my personal node-manta repository, adding the res argument to the callback of the modified function client.commitUpload and asserted that it is defined and checked that it's status code is 201, as is reflected in the test suite.

mmpu change in do_commit:

...
client.commitUpload(id, parts, commitUploadOpts, function (err, res) {
    if (err) {
        cb(err);
    } else {
        assert.ok(res);
        assert.ok(res.statusCode === 201);
        cb();
    }
});

Using this temporarily modified version of the mmpu command then returns successfully on commit.

[root@0e176aeb-3a6b-cf90-b846-9e1d293ac1ae ~/node-manta/bin]# export UUID = $(mmpu create ~~/stor/mpus/test.txt)
[root@0e176aeb-3a6b-cf90-b846-9e1d293ac1ae ~/node-manta/bin]# mmpu commit $UUID
[root@0e176aeb-3a6b-cf90-b846-9e1d293ac1ae ~/node-manta/bin]# echo $?
0