@@ -27,6 +27,7 @@ import (
2727 "github.com/stretchr/testify/assert"
2828 "github.com/stretchr/testify/require"
2929
30+ "github.com/snyk/snyk-ls/infrastructure/learn/mock_learn"
3031 ctx2 "github.com/snyk/snyk-ls/internal/context"
3132 "github.com/snyk/snyk-ls/internal/testutil"
3233 "github.com/snyk/snyk-ls/internal/types"
@@ -131,9 +132,18 @@ func Test_UnifiedIssue_HasUpgradeQuickFixAction(t *testing.T) {
131132 require .NoError (t , err )
132133 path := filepath .Join (workDir , "package.json" )
133134 ctx = ctx2 .NewContextWithWorkDirAndFilePath (ctx , types .FilePath (workDir ), types .FilePath (path ))
135+
136+ // Create learn service mock and inject into context (merge with existing dependencies)
137+ ctrl := gomock .NewController (t )
138+ learnMock := mock_learn .NewMockService (ctrl )
139+ learnMock .EXPECT ().GetLesson (gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any ()).Return (nil , nil ).AnyTimes ()
140+ deps , _ := ctx2 .DependenciesFromContext (ctx )
141+ deps [ctx2 .DepLearnService ] = learnMock
142+ ctx = ctx2 .NewContextWithDependencies (ctx , deps )
143+
134144 problems := asProblemsMap (ctx , []testapi.FindingData {finding })
135145 require .NotEmpty (t , problems )
136- // Enable OSS quick-fix actions (deps already injected by UnitTestWithCtx)
146+ // Enable OSS quick-fix actions
137147 c .SetSnykOSSQuickFixCodeActionsEnabled (true )
138148
139149 // Pick first problem group
@@ -182,6 +192,15 @@ func Test_UnifiedIssue_ProducesUpgradeCodeLens(t *testing.T) {
182192 require .NoError (t , err )
183193 path := filepath .Join (workDir , "package.json" )
184194 ctx = ctx2 .NewContextWithWorkDirAndFilePath (ctx , types .FilePath (workDir ), types .FilePath (path ))
195+
196+ // Create learn service mock and inject into context (merge with existing dependencies)
197+ ctrl := gomock .NewController (t )
198+ learnMock := mock_learn .NewMockService (ctrl )
199+ learnMock .EXPECT ().GetLesson (gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any ()).Return (nil , nil ).AnyTimes ()
200+ deps , _ := ctx2 .DependenciesFromContext (ctx )
201+ deps [ctx2 .DepLearnService ] = learnMock
202+ ctx = ctx2 .NewContextWithDependencies (ctx , deps )
203+
185204 problems := asProblemsMap (ctx , []testapi.FindingData {finding })
186205 require .NotEmpty (t , problems )
187206 // Enable OSS quick-fix actions
@@ -192,7 +211,7 @@ func Test_UnifiedIssue_ProducesUpgradeCodeLens(t *testing.T) {
192211 require .NoError (t , err )
193212 require .NotNil (t , issue )
194213
195- // deps already injected by UnitTestWithCtx
214+ // deps already injected above
196215 enriched := addUnifiedOssQuickFixesAndLenses (ctx , []types.Issue {issue })
197216 require .Len (t , enriched , 1 )
198217 enrichedIssue := enriched [0 ]
0 commit comments