2022-04-13 19:30:29 +03:00
|
|
|
module Tests.WaspJobTest (waspJob) where
|
|
|
|
|
|
|
|
import GoldenTest (GoldenTest, makeGoldenTest)
|
|
|
|
import ShellCommands
|
|
|
|
( appendToWaspFile,
|
|
|
|
cdIntoCurrentProject,
|
|
|
|
createFile,
|
2022-05-03 21:34:25 +03:00
|
|
|
setDbToPSQL,
|
2022-04-13 19:30:29 +03:00
|
|
|
waspCliCompile,
|
|
|
|
waspCliNew,
|
|
|
|
)
|
|
|
|
|
|
|
|
waspJob :: GoldenTest
|
|
|
|
waspJob = do
|
|
|
|
let entityDecl =
|
|
|
|
" job MySpecialJob { \n\
|
2022-05-03 21:34:25 +03:00
|
|
|
\ executor: PgBoss, \n\
|
|
|
|
\ perform: { \n\
|
|
|
|
\ fn: import { foo } from \"@ext/jobs/bar.js\" \n\
|
|
|
|
\ } \n\
|
2022-04-13 19:30:29 +03:00
|
|
|
\ } \n"
|
|
|
|
|
|
|
|
let jobFile =
|
|
|
|
" export const foo = async (args) => { \n\
|
|
|
|
\ return 1 \n\
|
|
|
|
\ } \n"
|
|
|
|
|
|
|
|
makeGoldenTest "waspJob" $
|
|
|
|
sequence
|
|
|
|
[ waspCliNew,
|
|
|
|
cdIntoCurrentProject,
|
2022-05-03 21:34:25 +03:00
|
|
|
setDbToPSQL,
|
2022-04-13 19:30:29 +03:00
|
|
|
appendToWaspFile entityDecl,
|
|
|
|
createFile jobFile "./ext/jobs" "bar.js",
|
|
|
|
waspCliCompile
|
|
|
|
]
|