Skip to content

Commit 7b8289b

Browse files
committed
Add some test cases
1 parent 887b71f commit 7b8289b

3 files changed

Lines changed: 33 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"wp-tool": "dist/bin/app.js"
99
},
1010
"scripts": {
11-
"build": "bun build ./src/bin/app.ts --compile --outfile wp-tool",
11+
"build": "bun build ./src/bin/app.ts --compile --minify --outfile wp-tool",
1212
"test": "bun run test:unit & bun run test:e2e",
1313
"test:unit": "vitest --project unit",
1414
"test:unit:coverage": "vitest run --project unit --coverage",

src/util/path.spec.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { describe, expect, test } from 'vitest';
2+
3+
import { getPHPErrorLogPath, getUnixPath, getWpSampleConfigPath } from './path';
4+
5+
const path = '/var/www/';
6+
const phpVer = '8.1';
7+
const identity = 'my.site';
8+
9+
describe('getUnixPath()', () => {
10+
test('return correct paths', () => {
11+
const { wp, php, nginx } = getUnixPath(path, phpVer, identity);
12+
expect(wp.sample).toBe('/var/www/wp-config-sample.php');
13+
expect(wp.config).toBe('/var/www/wp-config.php');
14+
expect(php.pool).toBe('/etc/php/8.1/fpm/pool.d');
15+
expect(php.www).toBe('/etc/php/8.1/fpm/pool.d/www.conf');
16+
expect(php.host).toBe('/etc/php/8.1/fpm/pool.d/my.site.conf');
17+
expect(nginx.host).toBe('/etc/nginx/sites-available/my.site');
18+
});
19+
});
20+
21+
describe('getWpSampleConfigPath()', () => {
22+
test('return correct paths', () => {
23+
expect(getWpSampleConfigPath(path)).toBe('/var/www/wp-config-sample.php');
24+
});
25+
});
26+
27+
describe('getPHPErrorLogPath()', () => {
28+
test('return correct paths', () => {
29+
expect(getPHPErrorLogPath(phpVer, identity)).toBe('/var/log/php8.1-fpm-my.site.log.error');
30+
});
31+
});

src/util/path.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function getWpSampleConfigPath(wpInstalledPath: string) {
2323
}
2424

2525
export function getWpConfigPath(wpInstalledPath: string) {
26-
return path.join(wpInstalledPath, 'wp-config-sample.php');
26+
return path.join(wpInstalledPath, 'wp-config.php');
2727
}
2828

2929
export function getPHPPoolDir(phpVer: string) {

0 commit comments

Comments
 (0)