Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit 5b49317

Browse files
fix: only look for relevant files in scanner test (#372)
The `scanner` tests would scan all files in the `coffee` fixtures directory to make sure the `all` and `selectFiles` methods work correctly. However, the initial scan would incorrectly capture `.DS_Store` files if they were present in the `coffee` directory.
1 parent 37399c2 commit 5b49317

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

system-test/test-install.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ debug.start({
5656
version: 'Some version'
5757
}
5858
});`,
59-
description: 'imports the module and starts with a complete `serviceContext`'
59+
description:
60+
'imports the module and starts with a complete `serviceContext`'
6061
},
6162
{
6263
code: `import * as debug from '@google-cloud/debug-agent';

test/test-scanner.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ const fixture = (file: string): string => {
2525

2626
import * as scanner from '../src/agent/io/scanner';
2727

28+
const COFFEE_FILES_REGEX = /^(.*\.js\.map)|(.*\.js)|(.*\.coffee)$/;
29+
2830
describe('scanner', () => {
2931

3032
describe('scan', () => {
@@ -44,19 +46,21 @@ describe('scanner', () => {
4446
});
4547

4648
it('should be able to return all file stats directly', (done) => {
47-
scanner.scan(true, fixture('coffee'), /.*$/).then((fileStats) => {
48-
const files = Object.keys(fileStats.all());
49-
assert.strictEqual(files.length, 3);
50-
done();
51-
});
49+
scanner.scan(true, fixture('coffee'), COFFEE_FILES_REGEX)
50+
.then((fileStats) => {
51+
const files = Object.keys(fileStats.all());
52+
assert.strictEqual(files.length, 3);
53+
done();
54+
});
5255
});
5356

5457
it('should be able to filter to return all file stats', (done) => {
55-
scanner.scan(true, fixture('coffee'), /.*$/).then((fileStats) => {
56-
const files = fileStats.selectFiles(/.*$/, '');
57-
assert.strictEqual(files.length, 3);
58-
done();
59-
});
58+
scanner.scan(true, fixture('coffee'), COFFEE_FILES_REGEX)
59+
.then((fileStats) => {
60+
const files = fileStats.selectFiles(/.*$/, '');
61+
assert.strictEqual(files.length, 3);
62+
done();
63+
});
6064
});
6165

6266
it('should be able to filter filenames', (done) => {

0 commit comments

Comments
 (0)