Skip to content

Commit ea6f039

Browse files
authored
Merge pull request #42 from hadson19/adhoc/handle-reusable-storage-bucket-and-flie
handle storage to reuse bucket and file by path
2 parents b726224 + a035ce3 commit ea6f039

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/storage-bucket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function MockStorageBucket(storage, name) {
1515
}
1616

1717
MockStorageBucket.prototype.file = function (name) {
18-
return new MockStorageFile(this, name);
18+
return this.files[name] || new MockStorageFile(this, name);
1919
};
2020

2121
MockStorageBucket.prototype.deleteFile = function (name) {

src/storage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ MockStorage.prototype.ref = function(path) {
4141
};
4242

4343
MockStorage.prototype.bucket = function(name) {
44-
return new MockStorageBucket(this, name);
44+
return this.buckets[name] || new MockStorageBucket(this, name);
4545
};
4646

4747
module.exports = MockStorage;

0 commit comments

Comments
 (0)