Skip to content

Commit 2246698

Browse files
committed
[INTERNAL] Fix and enhance tests
Also remove mtime from resources. Unknown why that got added in the first place
1 parent db7c03e commit 2246698

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

lib/adapters/AbstractAdapter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class AbstractAdapter extends AbstractReaderWriter {
106106
continue;
107107
}
108108
} else if (globPart === minimatch.GLOBSTAR) {
109-
return i;
109+
return {idx: i};
110110
} else { // Regex
111111
if (!globPart.test(basePathPart)) {
112112
return null;

lib/adapters/FileSystem.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ class FileSystem extends AbstractAdapter {
118118
statInfo: { // TODO: make closer to fs stat info
119119
isDirectory: function() {
120120
return true;
121-
},
122-
mtime: new Date()
121+
}
123122
},
124123
path: virPath
125124
}));

lib/adapters/Memory.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ class Memory extends AbstractAdapter {
3838
statInfo: { // TODO: make closer to fs stat info
3939
isDirectory: function() {
4040
return true;
41-
},
42-
mtime: new Date()
41+
}
4342
},
4443
path: this._virBasePath.slice(0, -1)
4544
})

test/lib/resources.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ test("Virtual RL: GLOB resources from application.a w/o virtual base path prefix
224224

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

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

255+
test("Virtual RL: GLOB virtual directory w/o virtual base path prefix and nodir: true", (t) => {
256+
const readerWriter = ui5Fs.resourceFactory.createAdapter({
257+
virBasePath: "/app/"
258+
});
259+
260+
// Get resource from one readerWriter
261+
return t.notThrows(
262+
readerWriter.byGlob("/*", {nodir: true})
263+
.then((resources) => {
264+
t.deepEqual(resources.length, 0, "Found exactly one resource");
265+
})
266+
);
267+
});
268+
269+
test("Virtual RL: GLOB virtual directory w/ virtual base path prefix and nodir: true", (t) => {
270+
const readerWriter = ui5Fs.resourceFactory.createAdapter({
271+
virBasePath: "/app/one/two/"
272+
});
273+
274+
// Get resource from one readerWriter
275+
return t.notThrows(
276+
readerWriter.byGlob("/*", {nodir: true})
277+
.then((resources) => {
278+
t.deepEqual(resources.length, 0, "Found exactly one resource");
279+
})
280+
);
281+
});
282+
257283
test("createCollectionsForTree", (t) => {
258284
// Creates resource reader collections for a given tree
259285
const resourceReaders = ui5Fs.resourceFactory.createCollectionsForTree(applicationBTree);

0 commit comments

Comments
 (0)