@@ -67,7 +67,7 @@ func TestManager_ExecutePurchase(t *testing.T) {
6767 }, nil )
6868
6969 // Mock provider factory to return a mock provider
70- mockFactory .On ("CreateAndValidateProvider" , mock .Anything , "aws" , mock .Anything ).Return (mockProviderInst , nil )
70+ mockFactory .On ("CreateAndValidateProvider" , mock .MatchedBy ( func ( c context. Context ) bool { _ , ok := c . Deadline (); return ok }) , "aws" , mock .Anything ).Return (mockProviderInst , nil )
7171 mockProviderInst .On ("GetServiceClient" , mock .MatchedBy (func (c context.Context ) bool { _ , ok := c .Deadline (); return ok }), common .ServiceEC2 , "us-east-1" ).Return (mockServiceClient , nil )
7272 mockServiceClient .On ("PurchaseCommitment" , mock .MatchedBy (func (c context.Context ) bool { _ , ok := c .Deadline (); return ok }), mock .AnythingOfType ("common.Recommendation" ), mock .AnythingOfType ("common.PurchaseOptions" )).Return (common.PurchaseResult {
7373 Success : true ,
@@ -127,7 +127,7 @@ func TestManager_ExecutePurchase_WebSourcePropagates(t *testing.T) {
127127 mockSTS .On ("GetCallerIdentity" , ctx , mock .AnythingOfType ("*sts.GetCallerIdentityInput" )).Return (& sts.GetCallerIdentityOutput {
128128 Account : aws .String ("123456789012" ),
129129 }, nil )
130- mockFactory .On ("CreateAndValidateProvider" , mock .Anything , "aws" , mock .Anything ).Return (mockProviderInst , nil )
130+ mockFactory .On ("CreateAndValidateProvider" , mock .MatchedBy ( func ( c context. Context ) bool { _ , ok := c . Deadline (); return ok }) , "aws" , mock .Anything ).Return (mockProviderInst , nil )
131131 mockProviderInst .On ("GetServiceClient" , mock .MatchedBy (func (c context.Context ) bool { _ , ok := c .Deadline (); return ok }), common .ServiceEC2 , "us-east-1" ).Return (mockServiceClient , nil )
132132 // The deterministic idempotency token (issue #636) is derived per-rec from
133133 // the execution ID and the rec's index, so the web path now also carries it.
@@ -183,7 +183,7 @@ func TestManager_ExecutePurchase_InvalidSourceFallsBackUntagged(t *testing.T) {
183183 mockSTS .On ("GetCallerIdentity" , ctx , mock .AnythingOfType ("*sts.GetCallerIdentityInput" )).Return (& sts.GetCallerIdentityOutput {
184184 Account : aws .String ("123456789012" ),
185185 }, nil )
186- mockFactory .On ("CreateAndValidateProvider" , mock .Anything , "aws" , mock .Anything ).Return (mockProviderInst , nil )
186+ mockFactory .On ("CreateAndValidateProvider" , mock .MatchedBy ( func ( c context. Context ) bool { _ , ok := c . Deadline (); return ok }) , "aws" , mock .Anything ).Return (mockProviderInst , nil )
187187 mockProviderInst .On ("GetServiceClient" , mock .MatchedBy (func (c context.Context ) bool { _ , ok := c .Deadline (); return ok }), common .ServiceEC2 , "us-east-1" ).Return (mockServiceClient , nil )
188188 // Expect EMPTY source, not "cudly-evil" — NormalizeSource must have wiped it.
189189 // The idempotency token (issue #636) is still derived regardless of source.
@@ -528,7 +528,7 @@ func TestManager_ExecutePurchase_MultiAccount(t *testing.T) {
528528 mockStore .On ("SavePurchaseHistory" , ctx , mock .AnythingOfType ("*config.PurchaseHistoryRecord" )).Return (nil ).Times (2 )
529529 mockEmail .On ("SendPurchaseConfirmation" , ctx , mock .AnythingOfType ("email.NotificationData" )).Return (nil ).Times (2 )
530530
531- mockFactory .On ("CreateAndValidateProvider" , mock .Anything , "aws" , mock .Anything ).Return (mockProvider , nil )
531+ mockFactory .On ("CreateAndValidateProvider" , mock .MatchedBy ( func ( c context. Context ) bool { _ , ok := c . Deadline (); return ok }) , "aws" , mock .Anything ).Return (mockProvider , nil )
532532 mockProvider .On ("GetServiceClient" , mock .MatchedBy (func (c context.Context ) bool { _ , ok := c .Deadline (); return ok }), common .ServiceEC2 , "us-east-1" ).Return (mockServiceClient , nil )
533533 mockServiceClient .On ("PurchaseCommitment" , mock .MatchedBy (func (c context.Context ) bool { _ , ok := c .Deadline (); return ok }), mock .AnythingOfType ("common.Recommendation" ), mock .AnythingOfType ("common.PurchaseOptions" )).Return (common.PurchaseResult {
534534 Success : true , CommitmentID : "ri-99999" ,
@@ -756,7 +756,7 @@ func TestExecuteMultiAccount_PartialFailure_IsolatesAccounts(t *testing.T) {
756756
757757 // Only account-V reaches the provider; account-I fails at credential resolution.
758758 // Use .Once() so testify fails if the factory is called for account-I as well.
759- mockFactory .On ("CreateAndValidateProvider" , mock .Anything , "aws" , mock .Anything ).Return (mockProviderInst , nil ).Once ()
759+ mockFactory .On ("CreateAndValidateProvider" , mock .MatchedBy ( func ( c context. Context ) bool { _ , ok := c . Deadline (); return ok }) , "aws" , mock .Anything ).Return (mockProviderInst , nil ).Once ()
760760 mockProviderInst .On ("GetServiceClient" , mock .MatchedBy (func (c context.Context ) bool { _ , ok := c .Deadline (); return ok }), common .ServiceEC2 , "us-east-1" ).Return (mockServiceClient , nil ).Once ()
761761 mockServiceClient .On ("PurchaseCommitment" , mock .MatchedBy (func (c context.Context ) bool { _ , ok := c .Deadline (); return ok }),
762762 mock .AnythingOfType ("common.Recommendation" ),
@@ -921,7 +921,7 @@ func TestExecuteMultiAccount_RunsAccountsInParallel(t *testing.T) {
921921 return nil
922922 }
923923
924- mockFactory .On ("CreateAndValidateProvider" , mock .Anything , "aws" , mock .Anything ).Return (mockProviderInst , nil ).Twice ()
924+ mockFactory .On ("CreateAndValidateProvider" , mock .MatchedBy ( func ( c context. Context ) bool { _ , ok := c . Deadline (); return ok }) , "aws" , mock .Anything ).Return (mockProviderInst , nil ).Twice ()
925925 mockProviderInst .On ("GetServiceClient" , mock .MatchedBy (func (c context.Context ) bool { _ , ok := c .Deadline (); return ok }), common .ServiceEC2 , "us-east-1" ).Return (mockServiceClient , nil ).Twice ()
926926
927927 // Each PurchaseCommitment call blocks for perCallDelay. Under serial
@@ -1039,7 +1039,7 @@ func TestExecutePurchase_SingleAccount_AzureUsesResolvedCreds(t *testing.T) {
10391039 // The core assertion: factory must receive a non-nil provCfg.
10401040 // Before the fix, nil was passed and Azure SDK fell back to DefaultAzureCredential.
10411041 // After the fix, resolveAzureProvider populates ProviderOverride on the config.
1042- mockFactory .On ("CreateAndValidateProvider" , mock .Anything , "azure" ,
1042+ mockFactory .On ("CreateAndValidateProvider" , mock .MatchedBy ( func ( c context. Context ) bool { _ , ok := c . Deadline (); return ok }) , "azure" ,
10431043 mock .MatchedBy (func (cfg * provider.ProviderConfig ) bool {
10441044 return cfg != nil && cfg .ProviderOverride != nil
10451045 }),
@@ -1168,7 +1168,7 @@ func TestExecutePurchase_AzureCanonicalServiceTypes(t *testing.T) {
11681168 Account : aws .String ("123456789012" ),
11691169 }, nil )
11701170
1171- mockFactory .On ("CreateAndValidateProvider" , mock .Anything , "azure" ,
1171+ mockFactory .On ("CreateAndValidateProvider" , mock .MatchedBy ( func ( c context. Context ) bool { _ , ok := c . Deadline (); return ok }) , "azure" ,
11721172 mock .MatchedBy (func (cfg * provider.ProviderConfig ) bool {
11731173 return cfg != nil && cfg .ProviderOverride != nil
11741174 }),
@@ -1391,7 +1391,7 @@ func TestManager_ExecuteAndFinalize_HistorySaveFailure_StaysVisible(t *testing.T
13911391 mockSTS .On ("GetCallerIdentity" , ctx , mock .AnythingOfType ("*sts.GetCallerIdentityInput" )).Return (& sts.GetCallerIdentityOutput {
13921392 Account : aws .String ("123456789012" ),
13931393 }, nil )
1394- mockFactory .On ("CreateAndValidateProvider" , mock .Anything , "aws" , mock .Anything ).Return (mockProviderInst , nil )
1394+ mockFactory .On ("CreateAndValidateProvider" , mock .MatchedBy ( func ( c context. Context ) bool { _ , ok := c . Deadline (); return ok }) , "aws" , mock .Anything ).Return (mockProviderInst , nil )
13951395 mockProviderInst .On ("GetServiceClient" , mock .MatchedBy (func (c context.Context ) bool { _ , ok := c .Deadline (); return ok }), common .ServiceEC2 , "us-east-1" ).Return (mockServiceClient , nil )
13961396 mockServiceClient .On ("PurchaseCommitment" , mock .MatchedBy (func (c context.Context ) bool { _ , ok := c .Deadline (); return ok }), mock .AnythingOfType ("common.Recommendation" ), mock .AnythingOfType ("common.PurchaseOptions" )).Return (common.PurchaseResult {
13971397 Success : true ,
@@ -1465,7 +1465,7 @@ func TestManager_ExecuteAndFinalize_SingleAccount_PartialSuccess(t *testing.T) {
14651465 Account : aws .String ("123456789012" ),
14661466 }, nil ).Maybe ()
14671467
1468- mockFactory .On ("CreateAndValidateProvider" , mock .Anything , "aws" , mock .Anything ).Return (mockProviderInst , nil )
1468+ mockFactory .On ("CreateAndValidateProvider" , mock .MatchedBy ( func ( c context. Context ) bool { _ , ok := c . Deadline (); return ok }) , "aws" , mock .Anything ).Return (mockProviderInst , nil )
14691469 mockProviderInst .On ("GetServiceClient" , mock .MatchedBy (func (c context.Context ) bool { _ , ok := c .Deadline (); return ok }), common .ServiceEC2 , "us-east-1" ).Return (mockServiceClient , nil )
14701470 // m5.large succeeds; c5.xlarge fails.
14711471 mockServiceClient .On ("PurchaseCommitment" , mock .MatchedBy (func (c context.Context ) bool { _ , ok := c .Deadline (); return ok }),
@@ -1547,7 +1547,7 @@ func TestExecuteForAccount_PartialSuccess(t *testing.T) {
15471547 },
15481548 }
15491549
1550- mockFactory .On ("CreateAndValidateProvider" , mock .Anything , "aws" , mock .Anything ).Return (mockProviderInst , nil )
1550+ mockFactory .On ("CreateAndValidateProvider" , mock .MatchedBy ( func ( c context. Context ) bool { _ , ok := c . Deadline (); return ok }) , "aws" , mock .Anything ).Return (mockProviderInst , nil )
15511551 mockProviderInst .On ("GetServiceClient" , mock .MatchedBy (func (c context.Context ) bool { _ , ok := c .Deadline (); return ok }), common .ServiceEC2 , "us-east-1" ).Return (mockServiceClient , nil )
15521552 mockServiceClient .On ("PurchaseCommitment" , mock .MatchedBy (func (c context.Context ) bool { _ , ok := c .Deadline (); return ok }),
15531553 mock .MatchedBy (func (r common.Recommendation ) bool { return r .ResourceType == "m5.large" }),
@@ -1685,7 +1685,7 @@ func TestManager_ExecutePurchase_SingleAccount_StampsTargetAccount(t *testing.T)
16851685 mockSTS .On ("GetCallerIdentity" , ctx , mock .AnythingOfType ("*sts.GetCallerIdentityInput" )).
16861686 Return (& sts.GetCallerIdentityOutput {Account : aws .String (hostAccount )}, nil ).Maybe ()
16871687
1688- mockFactory .On ("CreateAndValidateProvider" , mock .Anything , tc .provider , mock .Anything ).Return (mockProviderInst , nil )
1688+ mockFactory .On ("CreateAndValidateProvider" , mock .MatchedBy ( func ( c context. Context ) bool { _ , ok := c . Deadline (); return ok }) , tc .provider , mock .Anything ).Return (mockProviderInst , nil )
16891689 mockProviderInst .On ("GetServiceClient" , mock .MatchedBy (func (c context.Context ) bool { _ , ok := c .Deadline (); return ok }), tc .expectedType , tc .region ).Return (mockServiceClient , nil )
16901690 mockServiceClient .On ("PurchaseCommitment" , mock .MatchedBy (func (c context.Context ) bool { _ , ok := c .Deadline (); return ok }),
16911691 mock .AnythingOfType ("common.Recommendation" ),
0 commit comments