Skip to content

Commit

Permalink
bugfix: S3C-2052 Add error functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bbuchanan9 committed Aug 20, 2019
1 parent 5de8571 commit 9d02f86
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions lib/storage/metadata/in_memory/metastore.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,18 @@ function inc(str) {
}

const metastore = {
errors: {}, // Used for simulation of metadata errors.
// Used for simulation of metadata errors.
error: () => {},

setErrorFunc(func) {
this.error = func;
return this;
},

clearErrorFunc() {
this.error = () => {};
return this;
},

createBucket: (bucketName, bucketMD, log, cb) => {
process.nextTick(() => {
Expand Down Expand Up @@ -83,8 +94,9 @@ const metastore = {
},

putObject: (bucketName, objName, objVal, params, log, cb) => {
if (metastore.errors.putObject) {
return process.nextTick(() => cb(metastore.errors.putObject));
const err = metastore.error(metastore.putObject.name);
if (err) {
return process.nextTick(() => cb(err));
}
return process.nextTick(() => {
metastore.getBucketAttributes(bucketName, log, err => {
Expand Down Expand Up @@ -157,7 +169,11 @@ const metastore = {
},

getObject: (bucketName, objName, params, log, cb) => {
process.nextTick(() => {
const err = metastore.error(metastore.getObject.name, objName);
if (err) {
return process.nextTick(() => cb(err));
}
return process.nextTick(() => {
metastore.getBucketAttributes(bucketName, log, err => {
if (err) {
return cb(err);
Expand Down

0 comments on commit 9d02f86

Please sign in to comment.