@@ -7,7 +7,9 @@ import { homedir } from 'os'
77
88import { dirname } from 'path'
99import { fileURLToPath } from 'url'
10- import { ProviderInstance } from "../node_modules/@oceanprotocol/lib/dist/types/index" ;
10+ import {
11+ ProviderInstance
12+ } from "@oceanprotocol/lib" ;
1113
1214const execPromise = util . promisify ( exec ) ;
1315
@@ -65,6 +67,11 @@ describe("Ocean CLI Compute", function() {
6567 const output = await runCommand ( `npm run cli publish ${ metadataFile } ` ) ;
6668
6769 const jsonMatch = output . match ( / d i d : o p : [ a - f 0 - 9 ] { 64 } / ) ;
70+ if ( ! jsonMatch ) {
71+ console . error ( "Raw output:" , output ) ;
72+ throw new Error ( "Could not find compute environments in the output" ) ;
73+ }
74+
6875 try {
6976 computeDatasetDid = jsonMatch [ 0 ] ;
7077 } catch ( error ) {
@@ -141,6 +148,10 @@ describe("Ocean CLI Compute", function() {
141148 }
142149 const match = jsonMatch [ 0 ] . match ( / E x i t i n g c o m p u t e e n v i r o n m e n t s : \s * ( .* ) / s) ;
143150 const result = match ? match [ 1 ] . trim ( ) : null ;
151+ if ( ! result ) {
152+ console . error ( "Raw output:" , output ) ;
153+ throw new Error ( "Could not find compute environments in the output" ) ;
154+ }
144155
145156 let environments ;
146157 try {
@@ -166,6 +177,8 @@ describe("Ocean CLI Compute", function() {
166177 it ( "should initialize compute on compute dataset and algorithm" , async function ( ) {
167178 const computeEnvs = await ProviderInstance . getComputeEnvironments ( 'http://127.0.0.1:8001' ) ;
168179 const env = computeEnvs [ 0 ] ;
180+ expect ( env ) . to . be . an ( 'object' ) . and . to . not . be . null . and . to . not . be . undefined ;
181+
169182 console . log ( `env: ${ JSON . stringify ( env ) } ` )
170183 resources = [
171184 {
@@ -191,7 +204,10 @@ describe("Ocean CLI Compute", function() {
191204 }
192205 const match = jsonMatch [ 0 ] . match ( / i n i t i a l i z e c o m p u t e d e t a i l s : \s * ( .* ) / s) ;
193206 const result = match ? match [ 1 ] . trim ( ) : null ;
194-
207+ if ( ! result ) {
208+ console . error ( "Raw output:" , output ) ;
209+ throw new Error ( "Could not find initialize compute response in the output" ) ;
210+ }
195211 try {
196212 providerInitializeResponse = eval ( result ) ;
197213 } catch ( error ) {
@@ -215,6 +231,10 @@ describe("Ocean CLI Compute", function() {
215231 }
216232 const match = jsonMatch [ 0 ] . match ( / J o b I D : \s * ( .* ) / s) ;
217233 const result = match ? match [ 1 ] . trim ( ) : null ;
234+ if ( ! result ) {
235+ console . error ( "Raw output:" , output ) ;
236+ throw new Error ( "Could not find compute job in the output" ) ;
237+ }
218238 computeJobId = result
219239 expect ( computeJobId ) . to . be . a ( "string" ) ;
220240 } ) ;
0 commit comments