import { ExecuteResult } from '../executer/execute-result' ; import { WorkNodeStatus } from '../planner/work-node-status' ; export async function expectSuccessfulResult ( result ) { if ( ! result . success ) { for ( const nodeId of Object . keys ( result . nodes ) ) { const node = result . nodes [ nodeId ] ; if ( node . state . type === 'failed' ) { expect ( { nodeId , status : node . state . type , logs : await node . console . read ( ) , } ) . toEqual ( { nodeId , status : 'completed' , } ) ; } } } } function getNode ( result , name ) { const node = Object . values ( result . nodes ) . find ( ( n ) => n . name === name ) ; if ( ! node ) { throw new Error ( `could not find node ${ name }` ) ; } return node ; } export async function expectLog ( result , name , message ) { const node = getNode ( result , name ) ; const logs = await node . console . read ( ) ; expect ( logs . map ( ( l ) => l . message ) ) . toContain ( message ) ; } export async function expectContainsLog ( result , name , message ) { const node = getNode ( result , name ) ; const logs = await node . console . read ( ) ; expect ( logs . some ( ( l ) => l . message . indexOf ( message ) ) ) . toBeTruthy ( ) ; }