Skip to content

Commit b05a1e3

Browse files
committed
test: fix missing git config error and refactor fs import
1 parent e283768 commit b05a1e3

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

test/processors/getDiff.test.js

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const path = require('path');
22
const simpleGit = require('simple-git');
3-
const fs = require('fs');
3+
const fs = require('fs').promises;
44
const { Action } = require('../../src/proxy/actions');
55
const { exec } = require('../../src/proxy/processors/push-action/getDiff');
66

@@ -14,37 +14,24 @@ describe('getDiff', () => {
1414
before(async () => {
1515
// Create a temp repo to avoid mocking simple-git
1616
tempDir = path.join(__dirname, 'temp-test-repo');
17-
await fs.mkdir(tempDir, { recursive: true }, (err) => {
18-
if (err) {
19-
console.error(err);
20-
}
21-
});
17+
await fs.mkdir(tempDir, { recursive: true });
2218
git = simpleGit(tempDir);
2319

2420
await git.init();
25-
await fs.writeFile(path.join(tempDir, 'test.txt'), 'initial content', (err) => {
26-
if (err) {
27-
console.error(err);
28-
}
29-
});
21+
await git.addConfig('user.name', 'test');
22+
await git.addConfig('user.email', '[email protected]');
23+
24+
await fs.writeFile(path.join(tempDir, 'test.txt'), 'initial content');
3025
await git.add('.');
3126
await git.commit('initial commit');
3227
});
3328

3429
after(async () => {
35-
await fs.rmdir(tempDir, { recursive: true }, (err) => {
36-
if (err) {
37-
console.error(err);
38-
}
39-
});
30+
await fs.rmdir(tempDir, { recursive: true });
4031
});
4132

4233
it('should get diff between commits', async () => {
43-
await fs.writeFile(path.join(tempDir, 'test.txt'), 'modified content', (err) => {
44-
if (err) {
45-
console.error(err);
46-
}
47-
});
34+
await fs.writeFile(path.join(tempDir, 'test.txt'), 'modified content');
4835
await git.add('.');
4936
const commit = await git.commit('second commit');
5037

0 commit comments

Comments
 (0)