mirror of
https://github.com/sasjs/server.git
synced 2026-07-23 21:25:29 +00:00
fix: fix code.spec.ts failing on a fresh checkout (CI)
This commit is contained in:
@@ -16,6 +16,8 @@ sequenceDiagram
|
|||||||
|
|
||||||
Note over Pool,SAS: SESSION CREATION - happens ahead of any request,<br/>pool pre-warms up to 3 sessions (Session.ts:59-69)
|
Note over Pool,SAS: SESSION CREATION - happens ahead of any request,<br/>pool pre-warms up to 3 sessions (Session.ts:59-69)
|
||||||
Pool->>FS: createFile(code.sas, "") - empty dummy SYSIN (Session.ts:117-118)
|
Pool->>FS: createFile(code.sas, "") - empty dummy SYSIN (Session.ts:117-118)
|
||||||
|
Pool->>FS: readFile(sysInitCompiledPath) - compiled system-init<br/>macros, produced by `npm run compileSysInit` (Session.ts:105)
|
||||||
|
Note over Pool: throws if this file doesn't exist yet -<br/>session creation never reaches execFile below
|
||||||
Pool->>FS: createFile(autoexec.sas, autoExecContent) (Session.ts:108-114)
|
Pool->>FS: createFile(autoexec.sas, autoExecContent) (Session.ts:108-114)
|
||||||
Pool->>SAS: execFile(sasLoc, -SYSIN code.sas -AUTOEXEC autoexec.sas -LOG log.log ...) (Session.ts:127-147)
|
Pool->>SAS: execFile(sasLoc, -SYSIN code.sas -AUTOEXEC autoexec.sas -LOG log.log ...) (Session.ts:127-147)
|
||||||
activate SAS
|
activate SAS
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
import { createFile, fileExists } from '@sasjs/utils'
|
||||||
import { Express } from 'express'
|
import { Express } from 'express'
|
||||||
import mongoose, { Mongoose } from 'mongoose'
|
import mongoose, { Mongoose } from 'mongoose'
|
||||||
import { MongoMemoryServer } from 'mongodb-memory-server'
|
import { MongoMemoryServer } from 'mongodb-memory-server'
|
||||||
@@ -13,7 +14,8 @@ import {
|
|||||||
import {
|
import {
|
||||||
generateAccessToken,
|
generateAccessToken,
|
||||||
saveTokensInDB,
|
saveTokensInDB,
|
||||||
RunTimeType
|
RunTimeType,
|
||||||
|
sysInitCompiledPath
|
||||||
} from '../../../utils'
|
} from '../../../utils'
|
||||||
|
|
||||||
// Real, unmocked end-to-end test of the SAS execution pipeline (session
|
// Real, unmocked end-to-end test of the SAS execution pipeline (session
|
||||||
@@ -43,6 +45,17 @@ describe('code', () => {
|
|||||||
let permissionController: PermissionController
|
let permissionController: PermissionController
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
// SASSessionController.createSession() unconditionally reads this file
|
||||||
|
// (Session.ts:105) before it ever spawns the SAS process. It's normally
|
||||||
|
// produced by `npm run compileSysInit` (part of the `initial`/`build`
|
||||||
|
// scripts), which `npm test` does not run - so on a fresh checkout
|
||||||
|
// (e.g. CI, where "Run Unit Tests" happens before "Build Package") it
|
||||||
|
// doesn't exist yet. Content is irrelevant here since mockSas.js never
|
||||||
|
// interprets it; it just needs to exist and be readable.
|
||||||
|
if (!(await fileExists(sysInitCompiledPath))) {
|
||||||
|
await createFile(sysInitCompiledPath, '')
|
||||||
|
}
|
||||||
|
|
||||||
mongoServer = await MongoMemoryServer.create()
|
mongoServer = await MongoMemoryServer.create()
|
||||||
process.env.DB_CONNECT = mongoServer.getUri()
|
process.env.DB_CONNECT = mongoServer.getUri()
|
||||||
process.env.MODE = 'server'
|
process.env.MODE = 'server'
|
||||||
|
|||||||
Reference in New Issue
Block a user