11package targets
22
33import (
4- "context"
54 "testing"
65 "time"
76 "workspace-engine/pkg/changeset"
@@ -142,6 +141,7 @@ func TestBuildTargetIndex(t *testing.T) {
142141
143142// Test taint on Policy change (should taint all targets)
144143func TestTaintProcessor_PolicyChange_TaintsAll (t * testing.T ) {
144+ ctx := t .Context ()
145145 sc := statechange .NewChangeSet [any ]()
146146 st := store .New (sc )
147147
@@ -165,7 +165,7 @@ func TestTaintProcessor_PolicyChange_TaintsAll(t *testing.T) {
165165 cs .Record (changeset .ChangeTypeCreate , policy )
166166
167167 // Process
168- tp := NewTaintProcessor (st , cs , targets )
168+ tp := NewTaintProcessor (ctx , st , cs , targets )
169169 tainted := tp .Tainted ()
170170
171171 // Verify all targets are tainted
@@ -176,6 +176,7 @@ func TestTaintProcessor_PolicyChange_TaintsAll(t *testing.T) {
176176
177177// Test taint on System change (should taint all targets)
178178func TestTaintProcessor_SystemChange_TaintsAll (t * testing.T ) {
179+ ctx := t .Context ()
179180 sc := statechange .NewChangeSet [any ]()
180181 st := store .New (sc )
181182
@@ -199,7 +200,7 @@ func TestTaintProcessor_SystemChange_TaintsAll(t *testing.T) {
199200 cs .Record (changeset .ChangeTypeUpdate , system )
200201
201202 // Process
202- tp := NewTaintProcessor (st , cs , targets )
203+ tp := NewTaintProcessor (ctx , st , cs , targets )
203204 tainted := tp .Tainted ()
204205
205206 // Verify all targets are tainted
@@ -210,6 +211,7 @@ func TestTaintProcessor_SystemChange_TaintsAll(t *testing.T) {
210211
211212// Test taint on Environment change
212213func TestTaintProcessor_EnvironmentChange_TaintsEnvironmentTargets (t * testing.T ) {
214+ ctx := t .Context ()
213215 sc := statechange .NewChangeSet [any ]()
214216 st := store .New (sc )
215217
@@ -234,7 +236,7 @@ func TestTaintProcessor_EnvironmentChange_TaintsEnvironmentTargets(t *testing.T)
234236 cs .Record (changeset .ChangeTypeUpdate , env )
235237
236238 // Process
237- tp := NewTaintProcessor (st , cs , targets )
239+ tp := NewTaintProcessor (ctx , st , cs , targets )
238240 tainted := tp .Tainted ()
239241
240242 // Verify only env1 targets are tainted
@@ -245,6 +247,7 @@ func TestTaintProcessor_EnvironmentChange_TaintsEnvironmentTargets(t *testing.T)
245247
246248// Test taint on Deployment change
247249func TestTaintProcessor_DeploymentChange_TaintsDeploymentTargets (t * testing.T ) {
250+ ctx := t .Context ()
248251 sc := statechange .NewChangeSet [any ]()
249252 st := store .New (sc )
250253
@@ -268,7 +271,7 @@ func TestTaintProcessor_DeploymentChange_TaintsDeploymentTargets(t *testing.T) {
268271 cs .Record (changeset .ChangeTypeUpdate , dep )
269272
270273 // Process
271- tp := NewTaintProcessor (st , cs , targets )
274+ tp := NewTaintProcessor (ctx , st , cs , targets )
272275 tainted := tp .Tainted ()
273276
274277 // Verify only dep1 targets are tainted
@@ -279,6 +282,7 @@ func TestTaintProcessor_DeploymentChange_TaintsDeploymentTargets(t *testing.T) {
279282
280283// Test taint on DeploymentVersion change
281284func TestTaintProcessor_DeploymentVersionChange_TaintsDeploymentTargets (t * testing.T ) {
285+ ctx := t .Context ()
282286 sc := statechange .NewChangeSet [any ]()
283287 st := store .New (sc )
284288
@@ -302,7 +306,7 @@ func TestTaintProcessor_DeploymentVersionChange_TaintsDeploymentTargets(t *testi
302306 cs .Record (changeset .ChangeTypeCreate , version )
303307
304308 // Process
305- tp := NewTaintProcessor (st , cs , targets )
309+ tp := NewTaintProcessor (ctx , st , cs , targets )
306310 tainted := tp .Tainted ()
307311
308312 // Verify only dep1 targets are tainted
@@ -313,6 +317,7 @@ func TestTaintProcessor_DeploymentVersionChange_TaintsDeploymentTargets(t *testi
313317
314318// Test taint on Resource change
315319func TestTaintProcessor_ResourceChange_TaintsResourceTargets (t * testing.T ) {
320+ ctx := t .Context ()
316321 sc := statechange .NewChangeSet [any ]()
317322 st := store .New (sc )
318323
@@ -336,7 +341,7 @@ func TestTaintProcessor_ResourceChange_TaintsResourceTargets(t *testing.T) {
336341 cs .Record (changeset .ChangeTypeUpdate , resource )
337342
338343 // Process
339- tp := NewTaintProcessor (st , cs , targets )
344+ tp := NewTaintProcessor (ctx , st , cs , targets )
340345 tainted := tp .Tainted ()
341346
342347 // Verify only resID1 targets are tainted
@@ -347,7 +352,7 @@ func TestTaintProcessor_ResourceChange_TaintsResourceTargets(t *testing.T) {
347352
348353// Test taint on Job change
349354func TestTaintProcessor_JobChange_TaintsJobReleaseTarget (t * testing.T ) {
350- ctx := context . Background ()
355+ ctx := t . Context ()
351356 sc := statechange .NewChangeSet [any ]()
352357 st := store .New (sc )
353358
@@ -379,7 +384,7 @@ func TestTaintProcessor_JobChange_TaintsJobReleaseTarget(t *testing.T) {
379384 cs .Record (changeset .ChangeTypeUpdate , job )
380385
381386 // Process
382- tp := NewTaintProcessor (st , cs , targets )
387+ tp := NewTaintProcessor (ctx , st , cs , targets )
383388 tainted := tp .Tainted ()
384389
385390 // Verify only the target associated with the job's release is tainted
@@ -390,6 +395,7 @@ func TestTaintProcessor_JobChange_TaintsJobReleaseTarget(t *testing.T) {
390395
391396// Test taint with job that has non-existent release
392397func TestTaintProcessor_JobChange_NonExistentRelease (t * testing.T ) {
398+ ctx := t .Context ()
393399 sc := statechange .NewChangeSet [any ]()
394400 st := store .New (sc )
395401
@@ -409,7 +415,7 @@ func TestTaintProcessor_JobChange_NonExistentRelease(t *testing.T) {
409415 cs .Record (changeset .ChangeTypeUpdate , job )
410416
411417 // Process
412- tp := NewTaintProcessor (st , cs , targets )
418+ tp := NewTaintProcessor (ctx , st , cs , targets )
413419 tainted := tp .Tainted ()
414420
415421 // Verify no targets are tainted
@@ -418,6 +424,7 @@ func TestTaintProcessor_JobChange_NonExistentRelease(t *testing.T) {
418424
419425// Test multiple changes in single pass
420426func TestTaintProcessor_MultipleChanges_SinglePass (t * testing.T ) {
427+ ctx := t .Context ()
421428 sc := statechange .NewChangeSet [any ]()
422429 st := store .New (sc )
423430
@@ -450,7 +457,7 @@ func TestTaintProcessor_MultipleChanges_SinglePass(t *testing.T) {
450457 cs .Record (changeset .ChangeTypeUpdate , resource )
451458
452459 // Process
453- tp := NewTaintProcessor (st , cs , targets )
460+ tp := NewTaintProcessor (ctx , st , cs , targets )
454461 tainted := tp .Tainted ()
455462
456463 // Verify all targets are tainted (target1 by env+dep, target2 by dep+res, target3 by env+res)
@@ -462,6 +469,7 @@ func TestTaintProcessor_MultipleChanges_SinglePass(t *testing.T) {
462469
463470// Test empty changeset
464471func TestTaintProcessor_EmptyChangeset (t * testing.T ) {
472+ ctx := t .Context ()
465473 sc := statechange .NewChangeSet [any ]()
466474 st := store .New (sc )
467475
@@ -479,7 +487,7 @@ func TestTaintProcessor_EmptyChangeset(t *testing.T) {
479487 cs := changeset .NewChangeSet [any ]()
480488
481489 // Process
482- tp := NewTaintProcessor (st , cs , targets )
490+ tp := NewTaintProcessor (ctx , st , cs , targets )
483491 tainted := tp .Tainted ()
484492
485493 // Verify no targets are tainted
@@ -488,6 +496,7 @@ func TestTaintProcessor_EmptyChangeset(t *testing.T) {
488496
489497// Test that Policy change short-circuits (taints all and returns early)
490498func TestTaintProcessor_PolicyChange_ShortCircuits (t * testing.T ) {
499+ ctx := t .Context ()
491500 sc := statechange .NewChangeSet [any ]()
492501 st := store .New (sc )
493502
@@ -514,7 +523,7 @@ func TestTaintProcessor_PolicyChange_ShortCircuits(t *testing.T) {
514523 cs .Record (changeset .ChangeTypeUpdate , env )
515524
516525 // Process
517- tp := NewTaintProcessor (st , cs , targets )
526+ tp := NewTaintProcessor (ctx , st , cs , targets )
518527 tainted := tp .Tainted ()
519528
520529 // Verify all targets are tainted (policy should cause all to be tainted and return early)
@@ -525,6 +534,7 @@ func TestTaintProcessor_PolicyChange_ShortCircuits(t *testing.T) {
525534
526535// Test with no targets
527536func TestTaintProcessor_NoTargets (t * testing.T ) {
537+ ctx := t .Context ()
528538 sc := statechange .NewChangeSet [any ]()
529539 st := store .New (sc )
530540 targets := map [string ]* oapi.ReleaseTarget {}
@@ -535,7 +545,7 @@ func TestTaintProcessor_NoTargets(t *testing.T) {
535545 cs .Record (changeset .ChangeTypeUpdate , env )
536546
537547 // Process
538- tp := NewTaintProcessor (st , cs , targets )
548+ tp := NewTaintProcessor (ctx , st , cs , targets )
539549 tainted := tp .Tainted ()
540550
541551 // Verify no targets are tainted (because there are none)
@@ -544,6 +554,7 @@ func TestTaintProcessor_NoTargets(t *testing.T) {
544554
545555// Test taint deduplication (same target tainted by multiple changes)
546556func TestTaintProcessor_Deduplication (t * testing.T ) {
557+ ctx := t .Context ()
547558 sc := statechange .NewChangeSet [any ]()
548559 st := store .New (sc )
549560
@@ -568,7 +579,7 @@ func TestTaintProcessor_Deduplication(t *testing.T) {
568579 cs .Record (changeset .ChangeTypeUpdate , resource )
569580
570581 // Process
571- tp := NewTaintProcessor (st , cs , targets )
582+ tp := NewTaintProcessor (ctx , st , cs , targets )
572583 tainted := tp .Tainted ()
573584
574585 // Verify target is tainted only once (deduplication works)
0 commit comments