@@ -646,42 +646,42 @@ func TestDirector_HandleRequest(t *testing.T) {
646646 ds .PodUpdateOrAddIfNotExist (testPod )
647647 }
648648
649- for _ , test := range tests {
650- t .Run (test .name , func (t * testing.T ) {
651- mockSched := & mockScheduler {}
652- if test .schedulerMockSetup != nil {
653- test .schedulerMockSetup (mockSched )
654- }
655- config := NewConfig ()
656- if test .prepareDataPlugin != nil {
657- config = config .WithPrepareDataPlugins (test .prepareDataPlugin )
658- }
659- config = config .WithAdmissionPlugins (newMockAdmissionPlugin ("test-admit-plugin" , test .admitRequestDenialError ))
660-
661- locator := NewCachedPodLocator (context .Background (), NewDatastorePodLocator (ds ), time .Minute )
662- director := NewDirectorWithConfig (ds , mockSched , test .mockAdmissionController , locator , config )
663- if test .name == "successful request with model rewrite" {
664- mockDs := & mockDatastore {
665- pods : ds .PodList (datastore .AllPodsPredicate ),
666- rewrites : []* v1alpha2.InferenceModelRewrite {rewrite },
649+ for _ , test := range tests {
650+ t .Run (test .name , func (t * testing.T ) {
651+ mockSched := & mockScheduler {}
652+ if test .schedulerMockSetup != nil {
653+ test .schedulerMockSetup (mockSched )
654+ }
655+ config := NewConfig ()
656+ if test .prepareDataPlugin != nil {
657+ config = config .WithPrepareDataPlugins (test .prepareDataPlugin )
658+ }
659+ config = config .WithAdmissionPlugins (newMockAdmissionPlugin ("test-admit-plugin" , test .admitRequestDenialError ))
660+
661+ locator := NewCachedPodLocator (context .Background (), NewDatastorePodLocator (ds ), time .Minute )
662+ director := NewDirectorWithConfig (ds , mockSched , test .mockAdmissionController , locator , config )
663+ if test .name == "successful request with model rewrite" {
664+ mockDs := & mockDatastore {
665+ pods : ds .PodList (datastore .AllPodsPredicate ),
666+ rewrites : []* v1alpha2.InferenceModelRewrite {rewrite },
667+ }
668+ director .datastore = mockDs
669+ director .podLocator = NewCachedPodLocator (context .Background (), NewDatastorePodLocator (mockDs ), time .Minute )
667670 }
668- director .datastore = mockDs
669- director .podLocator = NewCachedPodLocator (context .Background (), NewDatastorePodLocator (mockDs ), time .Minute )
670- }
671671
672- reqCtx := & handlers.RequestContext {
673- Request : & handlers.Request {
674- // Create a copy of the map for each test run to avoid mutation issues.
675- Body : make (map [string ]any ),
676- Headers : map [string ]string {
677- requtil .RequestIdHeaderKey : "test-req-id-" + test .name , // Ensure a default request ID
672+ reqCtx := & handlers.RequestContext {
673+ Request : & handlers.Request {
674+ // Create a copy of the map for each test run to avoid mutation issues.
675+ Body : make (map [string ]any ),
676+ Headers : map [string ]string {
677+ requtil .RequestIdHeaderKey : "test-req-id-" + test .name , // Ensure a default request ID
678+ },
678679 },
679- },
680- ObjectiveKey : test .inferenceObjectiveName ,
681- TargetModelName : test .initialTargetModelName ,
682- }
683- // Deep copy the body map.
684- maps .Copy (reqCtx .Request .Body , test .reqBodyMap )
680+ ObjectiveKey : test .inferenceObjectiveName ,
681+ TargetModelName : test .initialTargetModelName ,
682+ }
683+ // Deep copy the body map.
684+ maps .Copy (reqCtx .Request .Body , test .reqBodyMap )
685685
686686 returnedReqCtx , err := director .HandleRequest (ctx , reqCtx )
687687
@@ -704,12 +704,13 @@ func TestDirector_HandleRequest(t *testing.T) {
704704 assert .Equal (t , test .wantReqCtx .TargetEndpoint , returnedReqCtx .TargetEndpoint , "reqCtx.TargetEndpoint mismatch" )
705705 }
706706
707- if test .wantMutatedBodyModel != "" {
708- assert .NotNil (t , returnedReqCtx .Request .Body , "Expected mutated body, but reqCtx.Request.Body is nil" )
709- assert .Equal (t , test .wantMutatedBodyModel , returnedReqCtx .Request .Body ["model" ],
710- "Mutated reqCtx.Request.Body model mismatch" )
711- }
712- })
707+ if test .wantMutatedBodyModel != "" {
708+ assert .NotNil (t , returnedReqCtx .Request .Body , "Expected mutated body, but reqCtx.Request.Body is nil" )
709+ assert .Equal (t , test .wantMutatedBodyModel , returnedReqCtx .Request .Body ["model" ],
710+ "Mutated reqCtx.Request.Body model mismatch" )
711+ }
712+ })
713+ }
713714 }
714715}
715716
0 commit comments