@@ -458,14 +458,14 @@ func TestEnabledIntegrationsDependencies(t *testing.T) {
458458 enabled : []string {"i1" },
459459 wantError : errIntegrationNotFound ,
460460 },
461- "dependecncy not enabled" : {
461+ "dependency not enabled" : {
462462 integrationsDependencies : map [string ][]string {
463463 "i1" : {"i2" },
464464 },
465465 enabled : []string {"i1" },
466466 wantError : errDependencyIntegrationNotEnabled ,
467467 },
468- "dependecncy not found" : {
468+ "dependency not found" : {
469469 integrationsDependencies : map [string ][]string {
470470 "i1" : {"i2" },
471471 },
@@ -486,8 +486,8 @@ func TestEnabledIntegrationsDependencies(t *testing.T) {
486486 manager := integrationManager {
487487 integrations : map [string ]IntegrationCallbacks {},
488488 }
489- for inegration , deps := range tc .integrationsDependencies {
490- manager .integrations [inegration ] = IntegrationCallbacks {
489+ for integration , deps := range tc .integrationsDependencies {
490+ manager .integrations [integration ] = IntegrationCallbacks {
491491 DependencyList : deps ,
492492 }
493493 }
@@ -498,3 +498,59 @@ func TestEnabledIntegrationsDependencies(t *testing.T) {
498498 })
499499 }
500500}
501+
502+ func TestImplicitlyEnabledIntegrations (t * testing.T ) {
503+ cases := map [string ]struct {
504+ integrationsImplicit map [string ][]string
505+ enabled []string
506+ wantImplicit []string
507+ }{
508+ "empty" : {},
509+ "no implicit dependencies" : {
510+ integrationsImplicit : map [string ][]string {
511+ "i1" : nil ,
512+ },
513+ enabled : []string {"i1" },
514+ wantImplicit : []string {},
515+ },
516+ "single implicit dependency" : {
517+ integrationsImplicit : map [string ][]string {
518+ "i1" : {"i2" },
519+ },
520+ enabled : []string {"i1" },
521+ wantImplicit : []string {"i2" },
522+ },
523+ "multiple implicit dependencies" : {
524+ integrationsImplicit : map [string ][]string {
525+ "i1" : {"i2" , "i3" },
526+ },
527+ enabled : []string {"i1" },
528+ wantImplicit : []string {"i2" , "i3" },
529+ },
530+ "nested implicit dependencies" : {
531+ integrationsImplicit : map [string ][]string {
532+ "i1" : {"i2" , "i3" },
533+ "i2" : {"i3" },
534+ "i3" : nil ,
535+ },
536+ enabled : []string {"i1" , "i2" },
537+ wantImplicit : []string {"i3" },
538+ },
539+ }
540+ for tcName , tc := range cases {
541+ t .Run (tcName , func (t * testing.T ) {
542+ mgr := integrationManager {
543+ integrations : map [string ]IntegrationCallbacks {},
544+ }
545+ for integration , implicitDeps := range tc .integrationsImplicit {
546+ mgr .integrations [integration ] = IntegrationCallbacks {
547+ ImplicitlyEnabledFrameworkNames : implicitDeps ,
548+ }
549+ }
550+ gotImplicit := mgr .collectImplicitlyEnabledIntegrations (sets .New (tc .enabled ... ))
551+ if diff := cmp .Diff (sets .New (tc .wantImplicit ... ), gotImplicit ); diff != "" {
552+ t .Errorf ("Unexpected implicitly enabled integrations (-want +got):\n %s" , diff )
553+ }
554+ })
555+ }
556+ }
0 commit comments