@@ -38,6 +38,10 @@ import {
3838import { checkManifestPlatform } from '../../components/c2d/compute_engine_docker.js'
3939import { ValidateParams } from '../../components/httpRoutes/validateCommands.js'
4040import { Readable } from 'stream'
41+ import sinon from 'sinon'
42+ import { getAlgoChecksums } from '../../components/core/compute/utils.js'
43+ import { FindDdoHandler } from '../../components/core/handler/ddoHandler.js'
44+ import { CORE_LOGGER } from '../../utils/logging/common.js'
4145
4246/* eslint-disable require-await */
4347class TestC2DEngine extends C2DEngine {
@@ -517,3 +521,33 @@ describe('Compute Jobs Database', () => {
517521 await tearDownEnvironment ( envOverrides )
518522 } )
519523} )
524+
525+ describe ( 'getAlgoChecksums' , ( ) => {
526+ let findDdoStub : sinon . SinonStub
527+ let loggerErrorSpy : sinon . SinonSpy
528+
529+ beforeEach ( ( ) => {
530+ findDdoStub = sinon . stub ( FindDdoHandler . prototype , 'findAndFormatDdo' )
531+ loggerErrorSpy = sinon . spy ( CORE_LOGGER , 'error' )
532+ } )
533+
534+ afterEach ( ( ) => {
535+ findDdoStub . restore ( )
536+ loggerErrorSpy . restore ( )
537+ } )
538+
539+ it ( 'returns empty checksums without a DDO lookup for raw-code algorithms (no documentId)' , async ( ) => {
540+ const checksums = await getAlgoChecksums (
541+ undefined ,
542+ undefined ,
543+ null as any ,
544+ null as any
545+ )
546+
547+ expect ( checksums ) . to . deep . equal ( { files : '' , container : '' , serviceId : undefined } )
548+ // no DDO lookup must be attempted when there is no algorithm documentId
549+ expect ( findDdoStub . called ) . to . equal ( false )
550+ // and therefore no "Algorithm with id: undefined not found!" error is logged
551+ expect ( loggerErrorSpy . called ) . to . equal ( false )
552+ } )
553+ } )
0 commit comments