import * as cloud from "@pulumi/cloud" ; import * as pulumi from "@pulumi/pulumi" ; import * as assertModule from "assert" ; import * as harness from "./harness" ; import * as apiTests from "./apiTests" ; import * as bucketTests from "./bucketTests" ; import * as serviceTests from "./serviceTests" ; import * as tableTests from "./tableTests" ; const endpoint = new cloud . API ( "tests-unittests" ) ; const testFunctions = [ bucketTests . runAllTests , tableTests . runAllTests , apiTests . runAllTests , serviceTests . runAllTests , ] ; async function testModules ( res ) { try { const assert = require ( "assert" ) ; const supertest = require ( "supertest" ) ; const arg = { assert , harness , supertest } ; const [ passed , json ] = await harness . testModulesWorker ( testFunctions , arg ) ; if ( passed ) { res . json ( json ) ; } else { res . status ( 500 ) . json ( json ) ; } } catch ( err ) { res . status ( 500 ) . json ( errorJSON ( err ) ) ; } } endpoint . get ( "/unittests" , async ( req , res ) => { try { await testModules ( res ) ; } catch ( err ) { res . status ( 500 ) . json ( errorJSON ( err ) ) ; } } ) ; function errorJSON ( err ) { const result = Object . create ( null ) ; Object . getOwnPropertyNames ( err ) . forEach ( key => result [ key ] = err [ key ] ) ; return result ; } const deployment = endpoint . publish ( ) ; export let url = deployment . url ;