Skip to content

Commit

Permalink
[INTERNAL] GLOB: Fix and enhance tests
Browse files Browse the repository at this point in the history
Also remove mtime from resources. Unknown why that got added in the first place
  • Loading branch information
RandomByte committed Jan 30, 2019
1 parent 34559e9 commit afbcc3f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/adapters/AbstractAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class AbstractAdapter extends AbstractReaderWriter {
continue;
}
} else if (globPart === minimatch.GLOBSTAR) {
return i;
return {idx: i};
} else { // Regex
if (!globPart.test(basePathPart)) {
return null;
Expand Down
3 changes: 1 addition & 2 deletions lib/adapters/FileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ class FileSystem extends AbstractAdapter {
statInfo: { // TODO: make closer to fs stat info
isDirectory: function() {
return true;
},
mtime: new Date()
}
},
path: virPath
}));
Expand Down
3 changes: 1 addition & 2 deletions lib/adapters/Memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ class Memory extends AbstractAdapter {
statInfo: { // TODO: make closer to fs stat info
isDirectory: function() {
return true;
},
mtime: new Date()
}
},
path: this._virBasePath.slice(0, -1)
})
Expand Down
30 changes: 28 additions & 2 deletions test/lib/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ test("Virtual RL: GLOB resources from application.a w/o virtual base path prefix

test("Virtual RL: GLOB virtual directory w/o virtual base path prefix", (t) => {
// TODO: Add similar test (globbing on empty directory) for FS RL
// TODO: Also add tests for nodir: true option
const readerWriter = ui5Fs.resourceFactory.createAdapter({
virBasePath: "/app/"
});
Expand All @@ -240,7 +239,6 @@ test("Virtual RL: GLOB virtual directory w/o virtual base path prefix", (t) => {

test("Virtual RL: GLOB virtual directory w/ virtual base path prefix", (t) => {
// TODO: Add similar test (globbing on empty directory) for FS RL
// TODO: Also add tests for nodir: true option
const readerWriter = ui5Fs.resourceFactory.createAdapter({
virBasePath: "/app/one/two/"
});
Expand All @@ -254,6 +252,34 @@ test("Virtual RL: GLOB virtual directory w/ virtual base path prefix", (t) => {
);
});

test("Virtual RL: GLOB virtual directory w/o virtual base path prefix and nodir: true", (t) => {
const readerWriter = ui5Fs.resourceFactory.createAdapter({
virBasePath: "/app/"
});

// Get resource from one readerWriter
return t.notThrows(
readerWriter.byGlob("/*", {nodir: true})
.then((resources) => {
t.deepEqual(resources.length, 0, "Found exactly one resource");
})
);
});

test("Virtual RL: GLOB virtual directory w/ virtual base path prefix and nodir: true", (t) => {
const readerWriter = ui5Fs.resourceFactory.createAdapter({
virBasePath: "/app/one/two/"
});

// Get resource from one readerWriter
return t.notThrows(
readerWriter.byGlob("/*", {nodir: true})
.then((resources) => {
t.deepEqual(resources.length, 0, "Found exactly one resource");
})
);
});

test("createCollectionsForTree", (t) => {
// Creates resource reader collections for a given tree
const resourceReaders = ui5Fs.resourceFactory.createCollectionsForTree(applicationBTree);
Expand Down

0 comments on commit afbcc3f

Please sign in to comment.