prettify code

This commit is contained in:
MS 2021-02-01 13:38:15 +01:00
parent c3ca3aa7fc
commit 69aaaefce3
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F
2 changed files with 34 additions and 53 deletions

View File

@ -116,8 +116,10 @@ interface WaitResult {
* Returns a new object being the current environment
* plus the values given in the parameter.
*/
export function extendEnv(extension: {[index: string]: string}): {[index: string]: string | undefined} {
let ret: {[index: string]: string | undefined} = {};
export function extendEnv(extension: {
[index: string]: string;
}): { [index: string]: string | undefined } {
let ret: { [index: string]: string | undefined } = {};
for (let v in process.env) {
ret[v] = process.env[v];
}
@ -190,7 +192,7 @@ export async function runCommand(
logName: string,
command: string,
args: string[],
env: {[index: string]: string | undefined} = process.env
env: { [index: string]: string | undefined } = process.env,
): Promise<string> {
console.log("runing command", shellescape([command, ...args]));
return new Promise((resolve, reject) => {
@ -198,7 +200,7 @@ export async function runCommand(
const proc = spawn(command, args, {
stdio: ["inherit", "pipe", "pipe"],
shell: false,
env: env
env: env,
});
proc.stdout.on("data", (x) => {
if (x instanceof Buffer) {
@ -340,14 +342,14 @@ export class GlobalTestState {
command: string,
args: string[],
logName: string,
env: {[index: string] : string | undefined} = process.env
env: { [index: string]: string | undefined } = process.env,
): ProcessWrapper {
console.log(
`spawning process (${logName}): ${shellescape([command, ...args])}`,
);
const proc = spawn(command, args, {
stdio: ["inherit", "pipe", "pipe"],
env: env
env: env,
});
console.log(`spawned process (${logName}) with pid ${proc.pid}`);
proc.on("error", (err) => {

View File

@ -24,7 +24,7 @@ import {
pingProc,
ProcessWrapper,
runCommand,
extendEnv
extendEnv,
} from "./harness";
export interface LibeufinSandboxServiceInterface {
@ -70,13 +70,11 @@ export class LibeufinSandboxService implements LibeufinSandboxServiceInterface {
async start(): Promise<void> {
this.sandboxProc = this.globalTestState.spawnService(
"libeufin-sandbox",
[
"serve",
"--port",
`${this.sandboxConfig.httpPort}`
],
["serve", "--port", `${this.sandboxConfig.httpPort}`],
"libeufin-sandbox",
extendEnv({LIBEUFIN_SANDBOX_DB_CONNECTION: this.sandboxConfig.databaseJdbcUri})
extendEnv({
LIBEUFIN_SANDBOX_DB_CONNECTION: this.sandboxConfig.databaseJdbcUri,
}),
);
}
@ -110,24 +108,19 @@ export class LibeufinNexusService {
this.globalTestState,
"libeufin-nexus-superuser",
"libeufin-nexus",
[
"superuser",
"admin",
"--password",
"test"
],
extendEnv({LIBEUFIN_NEXUS_DB_CONNECTION: this.nexusConfig.databaseJdbcUri})
["superuser", "admin", "--password", "test"],
extendEnv({
LIBEUFIN_NEXUS_DB_CONNECTION: this.nexusConfig.databaseJdbcUri,
}),
);
this.nexusProc = this.globalTestState.spawnService(
"libeufin-nexus",
[
"serve",
"--port",
`${this.nexusConfig.httpPort}`,
],
["serve", "--port", `${this.nexusConfig.httpPort}`],
"libeufin-nexus",
extendEnv({LIBEUFIN_NEXUS_DB_CONNECTION: this.nexusConfig.databaseJdbcUri})
extendEnv({
LIBEUFIN_NEXUS_DB_CONNECTION: this.nexusConfig.databaseJdbcUri,
}),
);
}
@ -284,7 +277,7 @@ export interface PostNexusPermissionRequest {
resourceType: string;
resourceId: string;
permissionName: string;
}
};
}
export namespace LibeufinNexusApi {
@ -411,20 +404,13 @@ export namespace LibeufinNexusApi {
req: CreateNexusUserRequest,
) {
const baseUrl = libeufinNexusService.baseUrl;
let url = new URL(
`/users`,
baseUrl,
);
await axios.post(
url.href,
req,
{
auth: {
username: "admin",
password: "test",
},
let url = new URL(`/users`, baseUrl);
await axios.post(url.href, req, {
auth: {
username: "admin",
password: "test",
},
);
});
}
export async function postPermission(
@ -432,20 +418,13 @@ export namespace LibeufinNexusApi {
req: PostNexusPermissionRequest,
) {
const baseUrl = libeufinNexusService.baseUrl;
let url = new URL(
`/permissions`,
baseUrl,
);
await axios.post(
url.href,
req,
{
auth: {
username: "admin",
password: "test",
},
let url = new URL(`/permissions`, baseUrl);
await axios.post(url.href, req, {
auth: {
username: "admin",
password: "test",
},
);
});
}
export async function createTwgFacade(