mirror of
https://github.com/s4u/maven-settings-action.git
synced 2026-02-18 00:00:26 +08:00
update dependency, code cleanup
This commit is contained in:
@ -1,3 +1,26 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2020 Slawomir Jaranowski and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
const process = require('process');
|
||||
const cp = require('child_process');
|
||||
const path = require('path');
|
||||
@ -24,30 +47,48 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
||||
try {
|
||||
fs.rmdirSync(path.dirname(settingsPath));
|
||||
} catch (error) {
|
||||
}
|
||||
|
||||
try {
|
||||
fs.rmdirSync(testHomePath);
|
||||
} catch (error) {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
test('run with default values', () => {
|
||||
|
||||
console.log(cp.execSync(`node ${indexPath}`, { env: process.env }).toString());
|
||||
function assertSetingsFile() {
|
||||
const settingsStatus = fs.lstatSync(settingsPath);
|
||||
expect(settingsStatus.isFile()).toBeTruthy();
|
||||
expect(settingsStatus.size).toBeGreaterThan(0);
|
||||
|
||||
const settingsBody = fs.readFileSync(settingsPath).toString();
|
||||
expect(settingsBody).toMatch('<settings>');
|
||||
}
|
||||
|
||||
test('run with default values', () => {
|
||||
|
||||
const out = cp.execSync(`node ${indexPath}`, { env: process.env }).toString();
|
||||
console.log(out);
|
||||
|
||||
assertSetingsFile();
|
||||
})
|
||||
|
||||
test('run with all feature', () => {
|
||||
|
||||
process.env['INPUT_SERVERES'] = '[{"id": "serverId", "username": "username", "password": "password"}]';
|
||||
process.env['INPUT_SERVERS'] = '[{"id": "serverId", "username": "username", "password": "password"}]';
|
||||
process.env['INPUT_PROPERTIES'] = '[{"prop1": "value1"}, {"prop2": "value2"}]'
|
||||
process.env['INPUT_SONATYPESNAPSHOT'] = true;
|
||||
|
||||
console.log(cp.execSync(`node ${indexPath}`, { env: process.env }).toString());
|
||||
const settingsStatus = fs.lstatSync(settingsPath);
|
||||
expect(settingsStatus.isFile()).toBeTruthy();
|
||||
expect(settingsStatus.size).toBeGreaterThan(0);
|
||||
const out = cp.execSync(`node ${indexPath}`, { env: process.env }).toString();
|
||||
console.log(out);
|
||||
|
||||
assertSetingsFile();
|
||||
|
||||
const settingsBody = fs.readFileSync(settingsPath).toString();
|
||||
expect(settingsBody).toMatch('<servers><server><id>serverId</id><username>username</username><password>password</password></server></servers>');
|
||||
expect(settingsBody).toMatch('prop1');
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user