@@ -5,7 +5,7 @@ import { Resource } from '../resource/resource.js';
55import { Plan } from '../plan/plan.js' ;
66import { spy } from 'sinon' ;
77import { ResourceSettings } from '../resource/resource-settings.js' ;
8- import { TestConfig } from '../utils/test-utils.test.js' ;
8+ import { TestConfig , TestStatefulParameter } from '../utils/test-utils.test.js' ;
99import { getPty } from '../pty/index.js' ;
1010
1111interface TestConfig extends StringIndexedObject {
@@ -389,5 +389,63 @@ describe('Plugin tests', () => {
389389 parameters : { path : '/my/path' , propA : 'hig' } ,
390390 } )
391391
392+ const match2 = await testPlugin . match ( {
393+ resource : {
394+ core : { type : 'testResource' } ,
395+ parameters : { path : '/my/path' , propA : 'abc' } ,
396+ } ,
397+ array : [ ]
398+ } )
399+
400+ expect ( match2 ) . toMatchObject ( {
401+ match : undefined ,
402+ } )
403+ } )
404+
405+ it ( 'Can match resources together 2' , { timeout : 3000000 } , async ( ) => {
406+ const resource = spy ( new class extends TestResource {
407+ getSettings ( ) : ResourceSettings < TestConfig > {
408+ return {
409+ id : 'ssh-config' ,
410+ parameterSettings : {
411+ hosts : { type : 'stateful' , definition : new TestStatefulParameter ( ) }
412+ } ,
413+ importAndDestroy : {
414+ refreshKeys : [ 'hosts' ] ,
415+ defaultRefreshValues : { hosts : [ ] } ,
416+ requiredParameters : [ ]
417+ } ,
418+ dependencies : [ 'ssh-key' ] ,
419+ allowMultiple : {
420+ matcher : ( a , b ) => a . hosts === b . hosts
421+ }
422+ }
423+ }
424+ } )
425+
426+ const testPlugin = Plugin . create ( 'testPlugin' , [ resource as any ] ) ;
427+
428+ const { match } = await testPlugin . match ( {
429+ resource : {
430+ core : { type : 'ssh-config' } ,
431+ parameters : { hosts : 'a' } ,
432+ } ,
433+ array : [
434+ {
435+ core : { type : 'ssh-config' } ,
436+ parameters : { hosts : 'b' } ,
437+ } ,
438+ {
439+ core : { type : 'ssh-config' } ,
440+ parameters : { hosts : 'a' } ,
441+ } ,
442+ {
443+ core : { type : 'ssh-config' } ,
444+ parameters : { hosts : 'c' } ,
445+ } ,
446+ ]
447+ } )
448+
449+ console . log ( match )
392450 } )
393451} ) ;
0 commit comments