Skip to content

Commit afbcc3f

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

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
@@ -110,7 +110,7 @@ class AbstractAdapter extends AbstractReaderWriter {
110110
continue;
111111
}
112112
} else if (globPart === minimatch.GLOBSTAR) {
113-
return i;
113+
return {idx: i};
114114
} else { // Regex
115115
if (!globPart.test(basePathPart)) {
116116
return null;

lib/adapters/FileSystem.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ class FileSystem extends AbstractAdapter {
120120
statInfo: { // TODO: make closer to fs stat info
121121
isDirectory: function() {
122122
return true;
123-
},
124-
mtime: new Date()
123+
}
125124
},
126125
path: virPath
127126
}));

lib/adapters/Memory.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ class Memory extends AbstractAdapter {
4242
statInfo: { // TODO: make closer to fs stat info
4343
isDirectory: function() {
4444
return true;
45-
},
46-
mtime: new Date()
45+
}
4746
},
4847
path: this._virBasePath.slice(0, -1)
4948
})

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)