1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-06 12:10:04 +00:00

chore(*): refactor, move all auth-related code to auth folder

This commit is contained in:
Krishna Acondy
2021-01-24 13:07:15 +00:00
parent e31774ae9d
commit aed39c2ec4
12 changed files with 342 additions and 266 deletions

View File

@@ -12,7 +12,7 @@ export const computeTests = (adapter: SASjs): TestSuite => ({
return adapter.startComputeJob("/Public/app/common/sendArr", data);
},
assertion: (res: any) => {
const expectedProperties = ["id", "applicationName", "attributes"]
const expectedProperties = ["id", "applicationName", "attributes"];
return validate(expectedProperties, res);
}
},
@@ -21,11 +21,22 @@ export const computeTests = (adapter: SASjs): TestSuite => ({
description: "Should start a compute job and return the job",
test: () => {
const data: any = { table1: [{ col1: "first col value" }] };
return adapter.startComputeJob("/Public/app/common/sendArr", data, {}, "", true);
return adapter.startComputeJob(
"/Public/app/common/sendArr",
data,
{},
"",
true
);
},
assertion: (res: any) => {
const expectedProperties = ["id", "state", "creationTimeStamp", "jobConditionCode"]
return validate(expectedProperties, res.result);
const expectedProperties = [
"id",
"state",
"creationTimeStamp",
"jobConditionCode"
];
return validate(expectedProperties, res.job);
}
},
{
@@ -38,19 +49,19 @@ export const computeTests = (adapter: SASjs): TestSuite => ({
`output;`,
`end;`,
`run;`
]
];
return adapter.executeScriptSASViya(
'sasCode.sas',
"sasCode.sas",
fileLines,
'SAS Studio compute context',
"SAS Studio compute context",
undefined,
true
)
);
},
assertion: (res: any) => {
const expectedLogContent = `1 data;\\n2 do x=1 to 100;\\n3 output;\\n4 end;\\n5 run;\\n\\n`
const expectedLogContent = `1 data;\\n2 do x=1 to 100;\\n3 output;\\n4 end;\\n5 run;\\n\\n`;
return validateLog(expectedLogContent, res.log);
}
},
@@ -58,21 +69,21 @@ export const computeTests = (adapter: SASjs): TestSuite => ({
title: "Execute Script Viya - failed job",
description: "Should execute sas file and return log",
test: () => {
const fileLines = [
`%abort;`
]
return adapter.executeScriptSASViya(
'sasCode.sas',
fileLines,
'SAS Studio compute context',
undefined,
true
).catch((err: any) => err )
const fileLines = [`%abort;`];
return adapter
.executeScriptSASViya(
"sasCode.sas",
fileLines,
"SAS Studio compute context",
undefined,
true
)
.catch((err: any) => err);
},
assertion: (res: any) => {
const expectedLogContent = `1 %abort;\\nERROR: The %ABORT statement is not valid in open code.\\n`
const expectedLogContent = `1 %abort;\\nERROR: The %ABORT statement is not valid in open code.\\n`;
return validateLog(expectedLogContent, res.log);
}
}
@@ -80,16 +91,16 @@ export const computeTests = (adapter: SASjs): TestSuite => ({
});
const validateLog = (text: string, log: string): boolean => {
const isValid = JSON.stringify(log).includes(text)
const isValid = JSON.stringify(log).includes(text);
return isValid
}
return isValid;
};
const validate = (expectedProperties: string[], data: any): boolean => {
const actualProperties = Object.keys(data);
const isValid = expectedProperties.every(
(property) => actualProperties.includes(property)
const isValid = expectedProperties.every((property) =>
actualProperties.includes(property)
);
return isValid
}
return isValid;
};

View File

@@ -23,11 +23,12 @@ export const sasjsRequestTests = (adapter: SASjs): TestSuite => ({
},
{
title: "Make error and capture log",
description: "Should make an error and capture log, in the same time it is testing if debug override is working",
description:
"Should make an error and capture log, in the same time it is testing if debug override is working",
test: async () => {
return new Promise(async (resolve, reject) => {
adapter
.request("common/makeErr", data, {debug: true})
.request("common/makeErr", data, { debug: true })
.then((res) => {
//no action here, this request must throw error
})
@@ -38,9 +39,11 @@ export const sasjsRequestTests = (adapter: SASjs): TestSuite => ({
req.serviceLink.includes("makeErr")
) || null;
if (!makeErrRequest) resolve(false)
if (!makeErrRequest) return resolve(false);
resolve(!!(makeErrRequest.logFile && makeErrRequest.logFile.length > 0));
return resolve(
!!(makeErrRequest.logFile && makeErrRequest.logFile.length > 0)
);
});
});
},