mirror of
https://github.com/sasjs/server.git
synced 2026-01-17 02:40:05 +00:00
chore: addressed comments
This commit is contained in:
@@ -68,7 +68,12 @@ MODE=
|
|||||||
# Priority is given to the runtime that comes first in the string.
|
# Priority is given to the runtime that comes first in the string.
|
||||||
# Possible options at the moment are sas and js
|
# Possible options at the moment are sas and js
|
||||||
|
|
||||||
# options: [sas|js|py|sas,js|js,sas|py,sas|sas,py|py,js|js,py|sas,js,py|sas,py,js|js,sas,py|js,py,sas|py,sas,js|py,js,sas] default:sas
|
# This string sets the priority of the available analytic runtimes
|
||||||
|
# Valid runtimes are SAS (sas), JavaScript (js) and Python (py)
|
||||||
|
# For each option provided, there should be a corresponding path,
|
||||||
|
# eg SAS_PATH, NODE_PATH or PYTHON_PATH
|
||||||
|
# Priority is given to runtimes earlier in the string
|
||||||
|
# Example options: [sas,js,py | js,py | sas | sas,js]
|
||||||
RUN_TIMES=
|
RUN_TIMES=
|
||||||
|
|
||||||
# Path to SAS executable (sas.exe / sas.sh)
|
# Path to SAS executable (sas.exe / sas.sh)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ HELMET_COEP=[true|false] if omitted HELMET default will be used
|
|||||||
|
|
||||||
DB_CONNECT=mongodb+srv://<DB_USERNAME>:<DB_PASSWORD>@<CLUSTER>/<DB_NAME>?retryWrites=true&w=majority
|
DB_CONNECT=mongodb+srv://<DB_USERNAME>:<DB_PASSWORD>@<CLUSTER>/<DB_NAME>?retryWrites=true&w=majority
|
||||||
|
|
||||||
RUN_TIMES=[sas|js|py|sas,js|js,sas|py,sas|sas,py|py,js|js,py|sas,js,py|sas,py,js|js,sas,py|js,py,sas|py,sas,js|py,js,sas] default considered as sas
|
RUN_TIMES=[sas,js,py | js,py | sas | sas,js] default considered as sas
|
||||||
SAS_PATH=/opt/sas/sas9/SASHome/SASFoundation/9.4/sas
|
SAS_PATH=/opt/sas/sas9/SASHome/SASFoundation/9.4/sas
|
||||||
NODE_PATH=~/.nvm/versions/node/v16.14.0/bin/node
|
NODE_PATH=~/.nvm/versions/node/v16.14.0/bin/node
|
||||||
PYTHON_PATH=/usr/bin/python
|
PYTHON_PATH=/usr/bin/python
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ const sampleJsProgram = `console.log('hello world!/')`
|
|||||||
const samplePyProgram = `print('hello world!/')`
|
const samplePyProgram = `print('hello world!/')`
|
||||||
|
|
||||||
const filesFolder = getFilesFolder()
|
const filesFolder = getFilesFolder()
|
||||||
|
const testFilesFolder = `test-stp-${generateTimestamp()}`
|
||||||
|
|
||||||
let app: Express
|
let app: Express
|
||||||
let accessToken: string
|
let accessToken: string
|
||||||
@@ -75,8 +76,6 @@ describe('stp', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('execute', () => {
|
describe('execute', () => {
|
||||||
const testFilesFolder = `test-stp-${generateTimestamp()}`
|
|
||||||
|
|
||||||
describe('get', () => {
|
describe('get', () => {
|
||||||
describe('with runtime js', () => {
|
describe('with runtime js', () => {
|
||||||
const testFilesFolder = `test-stp-${generateTimestamp()}`
|
const testFilesFolder = `test-stp-${generateTimestamp()}`
|
||||||
@@ -96,21 +95,15 @@ describe('stp', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should execute js program when both js and sas program are present', async () => {
|
it('should execute js program when both js and sas program are present', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert(
|
||||||
const sasProgramPath = path.join(filesFolder, `${programPath}.sas`)
|
[RunTimeType.JS, RunTimeType.SAS],
|
||||||
const jsProgramPath = path.join(filesFolder, `${programPath}.js`)
|
200,
|
||||||
await createFile(sasProgramPath, sampleSasProgram)
|
RunTimeType.JS
|
||||||
await createFile(jsProgramPath, sampleJsProgram)
|
)
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.JS)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should throw error when js program is not present but sas program exists', async () => {
|
it('should throw error when js program is not present but sas program exists', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert([], 400)
|
||||||
const sasProgramPath = path.join(filesFolder, `${programPath}.sas`)
|
|
||||||
await createFile(sasProgramPath, sampleSasProgram)
|
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 400)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -132,23 +125,15 @@ describe('stp', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should execute python program when python, js and sas programs are present', async () => {
|
it('should execute python program when python, js and sas programs are present', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert(
|
||||||
const sasProgramPath = path.join(filesFolder, `${programPath}.sas`)
|
[RunTimeType.PY, RunTimeType.SAS, RunTimeType.JS],
|
||||||
const jsProgramPath = path.join(filesFolder, `${programPath}.js`)
|
200,
|
||||||
const pyProgramPath = path.join(filesFolder, `${programPath}.py`)
|
RunTimeType.PY
|
||||||
await createFile(sasProgramPath, sampleSasProgram)
|
)
|
||||||
await createFile(jsProgramPath, sampleJsProgram)
|
|
||||||
await createFile(pyProgramPath, samplePyProgram)
|
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.PY)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should throw error when py program is not present but js or sas program exists', async () => {
|
it('should throw error when py program is not present but js or sas program exists', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert([], 400)
|
||||||
const sasProgramPath = path.join(filesFolder, `${programPath}.sas`)
|
|
||||||
await createFile(sasProgramPath, sampleSasProgram)
|
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 400)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -168,21 +153,11 @@ describe('stp', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should execute sas program when both sas and js programs are present', async () => {
|
it('should execute sas program when both sas and js programs are present', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert([RunTimeType.SAS], 200, RunTimeType.SAS)
|
||||||
const sasProgramPath = path.join(filesFolder, `${programPath}.sas`)
|
|
||||||
const jsProgramPath = path.join(filesFolder, `${programPath}.js`)
|
|
||||||
await createFile(sasProgramPath, sampleSasProgram)
|
|
||||||
await createFile(jsProgramPath, sampleJsProgram)
|
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.SAS)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should throw error when sas program do not exit but js exists', async () => {
|
it('should throw error when sas program do not exit but js exists', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert([], 400)
|
||||||
const jsProgramPath = path.join(filesFolder, `${programPath}.js`)
|
|
||||||
await createFile(jsProgramPath, sampleJsProgram)
|
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 400)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -202,27 +177,19 @@ describe('stp', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should execute js program when both js and sas program are present', async () => {
|
it('should execute js program when both js and sas program are present', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert(
|
||||||
const sasProgramPath = path.join(filesFolder, `${programPath}.sas`)
|
[RunTimeType.SAS, RunTimeType.JS],
|
||||||
const jsProgramPath = path.join(filesFolder, `${programPath}.js`)
|
200,
|
||||||
await createFile(sasProgramPath, sampleSasProgram)
|
RunTimeType.JS
|
||||||
await createFile(jsProgramPath, sampleJsProgram)
|
)
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.JS)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should execute sas program when js program is not present but sas program exists', async () => {
|
it('should execute sas program when js program is not present but sas program exists', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert([RunTimeType.SAS], 200, RunTimeType.SAS)
|
||||||
const sasProgramPath = path.join(filesFolder, `${programPath}.sas`)
|
|
||||||
await createFile(sasProgramPath, sampleSasProgram)
|
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.SAS)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should throw error when both sas and js programs do not exist', async () => {
|
it('should throw error when both sas and js programs do not exist', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert([], 400)
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 400)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -242,27 +209,19 @@ describe('stp', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should execute python program when both python and sas program are present', async () => {
|
it('should execute python program when both python and sas program are present', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert(
|
||||||
const sasProgramPath = path.join(filesFolder, `${programPath}.sas`)
|
[RunTimeType.PY, RunTimeType.SAS],
|
||||||
const pyProgramPath = path.join(filesFolder, `${programPath}.py`)
|
200,
|
||||||
await createFile(sasProgramPath, sampleSasProgram)
|
RunTimeType.PY
|
||||||
await createFile(pyProgramPath, samplePyProgram)
|
)
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.PY)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should execute sas program when python program is not present but sas program exists', async () => {
|
it('should execute sas program when python program is not present but sas program exists', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert([RunTimeType.SAS], 200, RunTimeType.SAS)
|
||||||
const sasProgramPath = path.join(filesFolder, `${programPath}.sas`)
|
|
||||||
await createFile(sasProgramPath, sampleSasProgram)
|
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.SAS)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should throw error when both sas and js programs do not exist', async () => {
|
it('should throw error when both sas and js programs do not exist', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert([], 400)
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 400)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -282,27 +241,19 @@ describe('stp', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should execute sas program when both sas and js programs exist', async () => {
|
it('should execute sas program when both sas and js programs exist', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert(
|
||||||
const sasProgramPath = path.join(filesFolder, `${programPath}.sas`)
|
[RunTimeType.SAS, RunTimeType.JS],
|
||||||
const jsProgramPath = path.join(filesFolder, `${programPath}.js`)
|
200,
|
||||||
await createFile(sasProgramPath, sampleSasProgram)
|
RunTimeType.SAS
|
||||||
await createFile(jsProgramPath, sampleJsProgram)
|
)
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.SAS)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should execute js program when sas program is not present but js program exists', async () => {
|
it('should execute js program when sas program is not present but js program exists', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert([RunTimeType.JS], 200, RunTimeType.JS)
|
||||||
const jsProgramPath = path.join(filesFolder, `${programPath}.js`)
|
|
||||||
await createFile(jsProgramPath, sampleJsProgram)
|
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.JS)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should throw error when both sas and js programs do not exist', async () => {
|
it('should throw error when both sas and js programs do not exist', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert([], 400)
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 400)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -322,27 +273,19 @@ describe('stp', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should execute sas program when both sas and python programs exist', async () => {
|
it('should execute sas program when both sas and python programs exist', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert(
|
||||||
const sasProgramPath = path.join(filesFolder, `${programPath}.sas`)
|
[RunTimeType.SAS, RunTimeType.PY],
|
||||||
const pyProgramPath = path.join(filesFolder, `${programPath}.py`)
|
200,
|
||||||
await createFile(sasProgramPath, sampleSasProgram)
|
RunTimeType.SAS
|
||||||
await createFile(pyProgramPath, samplePyProgram)
|
)
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.SAS)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should execute python program when sas program is not present but python program exists', async () => {
|
it('should execute python program when sas program is not present but python program exists', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert([RunTimeType.PY], 200, RunTimeType.PY)
|
||||||
const pyProgramPath = path.join(filesFolder, `${programPath}.py`)
|
|
||||||
await createFile(pyProgramPath, samplePyProgram)
|
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.PY)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should throw error when both sas and python programs do not exist', async () => {
|
it('should throw error when both sas and python programs do not exist', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert([], 400)
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 400)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -362,39 +305,27 @@ describe('stp', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should execute sas program when it exists, no matter js and python programs exist or not', async () => {
|
it('should execute sas program when it exists, no matter js and python programs exist or not', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert(
|
||||||
const sasProgramPath = path.join(filesFolder, `${programPath}.sas`)
|
[RunTimeType.SAS, RunTimeType.PY, RunTimeType.JS],
|
||||||
const jsProgramPath = path.join(filesFolder, `${programPath}.js`)
|
200,
|
||||||
const pyProgramPath = path.join(filesFolder, `${programPath}.py`)
|
RunTimeType.SAS
|
||||||
await createFile(sasProgramPath, sampleSasProgram)
|
)
|
||||||
await createFile(jsProgramPath, sampleJsProgram)
|
|
||||||
await createFile(pyProgramPath, samplePyProgram)
|
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.SAS)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should execute js program when sas program is absent but js and python programs are present', async () => {
|
it('should execute js program when sas program is absent but js and python programs are present', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert(
|
||||||
const jsProgramPath = path.join(filesFolder, `${programPath}.js`)
|
[RunTimeType.JS, RunTimeType.PY],
|
||||||
const pyProgramPath = path.join(filesFolder, `${programPath}.py`)
|
200,
|
||||||
await createFile(jsProgramPath, sampleJsProgram)
|
RunTimeType.JS
|
||||||
await createFile(pyProgramPath, samplePyProgram)
|
)
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.JS)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should execute python program when both sas and js programs are not present', async () => {
|
it('should execute python program when both sas and js programs are not present', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert([RunTimeType.PY], 200, RunTimeType.PY)
|
||||||
const pyProgramPath = path.join(filesFolder, `${programPath}.py`)
|
|
||||||
await createFile(pyProgramPath, samplePyProgram)
|
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.PY)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should throw error when no program exists', async () => {
|
it('should throw error when no program exists', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert([], 400)
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 400)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -414,39 +345,27 @@ describe('stp', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should execute js program when it exists, no matter sas and python programs exist or not', async () => {
|
it('should execute js program when it exists, no matter sas and python programs exist or not', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert(
|
||||||
const jsProgramPath = path.join(filesFolder, `${programPath}.js`)
|
[RunTimeType.JS, RunTimeType.SAS, RunTimeType.PY],
|
||||||
const sasProgramPath = path.join(filesFolder, `${programPath}.sas`)
|
200,
|
||||||
const pyProgramPath = path.join(filesFolder, `${programPath}.py`)
|
RunTimeType.JS
|
||||||
await createFile(jsProgramPath, sampleJsProgram)
|
)
|
||||||
await createFile(sasProgramPath, sampleSasProgram)
|
|
||||||
await createFile(pyProgramPath, samplePyProgram)
|
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.JS)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should execute sas program when js program is absent but sas and python programs are present', async () => {
|
it('should execute sas program when js program is absent but sas and python programs are present', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert(
|
||||||
const sasProgramPath = path.join(filesFolder, `${programPath}.sas`)
|
[RunTimeType.SAS, RunTimeType.PY],
|
||||||
const pyProgramPath = path.join(filesFolder, `${programPath}.py`)
|
200,
|
||||||
await createFile(sasProgramPath, sampleSasProgram)
|
RunTimeType.SAS
|
||||||
await createFile(pyProgramPath, samplePyProgram)
|
)
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.SAS)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should execute python program when both sas and js programs are not present', async () => {
|
it('should execute python program when both sas and js programs are not present', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert([RunTimeType.PY], 200, RunTimeType.PY)
|
||||||
const pyProgramPath = path.join(filesFolder, `${programPath}.py`)
|
|
||||||
await createFile(pyProgramPath, samplePyProgram)
|
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.PY)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should throw error when no program exists', async () => {
|
it('should throw error when no program exists', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert([], 400)
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 400)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -466,38 +385,27 @@ describe('stp', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should execute python program when it exists, no matter sas and js programs exist or not', async () => {
|
it('should execute python program when it exists, no matter sas and js programs exist or not', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert(
|
||||||
const pyProgramPath = path.join(filesFolder, `${programPath}.py`)
|
[RunTimeType.PY, RunTimeType.SAS, RunTimeType.JS],
|
||||||
const sasProgramPath = path.join(filesFolder, `${programPath}.sas`)
|
200,
|
||||||
const jsProgramPath = path.join(filesFolder, `${programPath}.js`)
|
RunTimeType.PY
|
||||||
await createFile(pyProgramPath, samplePyProgram)
|
)
|
||||||
await createFile(jsProgramPath, sampleJsProgram)
|
|
||||||
await createFile(sasProgramPath, sampleSasProgram)
|
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.PY)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should execute sas program when python program is absent but sas and js programs are present', async () => {
|
it('should execute sas program when python program is absent but sas and js programs are present', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert(
|
||||||
const sasProgramPath = path.join(filesFolder, `${programPath}.sas`)
|
[RunTimeType.SAS, RunTimeType.JS],
|
||||||
const jsProgramPath = path.join(filesFolder, `${programPath}.js`)
|
200,
|
||||||
await createFile(sasProgramPath, sampleSasProgram)
|
RunTimeType.SAS
|
||||||
await createFile(jsProgramPath, sampleJsProgram)
|
)
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.SAS)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should execute js program when both sas and python programs are not present', async () => {
|
it('should execute js program when both sas and python programs are not present', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert([RunTimeType.JS], 200, RunTimeType.JS)
|
||||||
const jsProgramPath = path.join(filesFolder, `${programPath}.js`)
|
|
||||||
await createFile(jsProgramPath, sampleJsProgram)
|
|
||||||
|
|
||||||
await makeRequestAndAssert(programPath, 200, RunTimeType.JS)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should throw error when no program exists', async () => {
|
it('should throw error when no program exists', async () => {
|
||||||
const programPath = path.join(testFilesFolder, 'program')
|
await makeRequestAndAssert([], 400)
|
||||||
await makeRequestAndAssert(programPath, 400)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -505,10 +413,29 @@ describe('stp', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const makeRequestAndAssert = async (
|
const makeRequestAndAssert = async (
|
||||||
programPath: string,
|
programTypes: RunTimeType[],
|
||||||
expectedStatusCode: number,
|
expectedStatusCode: number,
|
||||||
expectedRuntime?: RunTimeType
|
expectedRuntime?: RunTimeType
|
||||||
) => {
|
) => {
|
||||||
|
const programPath = path.join(testFilesFolder, 'program')
|
||||||
|
for (const programType of programTypes) {
|
||||||
|
if (programType === RunTimeType.JS)
|
||||||
|
await createFile(
|
||||||
|
path.join(filesFolder, `${programPath}.js`),
|
||||||
|
sampleJsProgram
|
||||||
|
)
|
||||||
|
else if (programType === RunTimeType.PY)
|
||||||
|
await createFile(
|
||||||
|
path.join(filesFolder, `${programPath}.py`),
|
||||||
|
samplePyProgram
|
||||||
|
)
|
||||||
|
else if (programType === RunTimeType.SAS)
|
||||||
|
await createFile(
|
||||||
|
path.join(filesFolder, `${programPath}.sas`),
|
||||||
|
sampleSasProgram
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
await request(app)
|
await request(app)
|
||||||
.get(`/SASjsApi/stp/execute?_program=${programPath}`)
|
.get(`/SASjsApi/stp/execute?_program=${programPath}`)
|
||||||
.auth(accessToken, { type: 'bearer' })
|
.auth(accessToken, { type: 'bearer' })
|
||||||
|
|||||||
Reference in New Issue
Block a user