Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/multi_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ func TestProcessPurchaseLoopEmptyRecommendations(t *testing.T) {
results := processPurchaseLoop(ctx, []common.Recommendation{}, "us-east-1", false, mockClient, toolCfg)

assert.Empty(t, results)
mockClient.AssertNotCalled(t, "PurchaseCommitment")
mockClient.AssertNotCalled(t, "PurchaseCommitment", mock.Anything, mock.Anything, mock.Anything)
}

func TestProcessServicePurchasesUserCancellation(t *testing.T) {
Expand Down Expand Up @@ -1408,7 +1408,7 @@ func TestProcessServicePurchasesDryRunMultiple(t *testing.T) {
assert.Equal(t, recs[i].ResourceType, result.Recommendation.ResourceType)
}

mockClient.AssertNotCalled(t, "PurchaseCommitment")
mockClient.AssertNotCalled(t, "PurchaseCommitment", mock.Anything, mock.Anything, mock.Anything)
}

// ==================== New Extracted Function Tests ====================
Expand Down Expand Up @@ -1483,7 +1483,7 @@ func TestProcessPurchaseLoopDryRun(t *testing.T) {
}

// Mock should not be called in dry run mode
mockClient.AssertNotCalled(t, "PurchaseCommitment")
mockClient.AssertNotCalled(t, "PurchaseCommitment", mock.Anything, mock.Anything, mock.Anything)
}

func TestProcessPurchaseLoopActualPurchase(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion internal/api/executed_notification_flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/LeanerCloud/CUDly/internal/email"
"github.com/aws/aws-lambda-go/events"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -244,7 +245,7 @@ func TestExecutedNotification_SessionApprovePath(t *testing.T) {
// Admin approved, so the executor recorded in the body is the admin.
assertExecutedNotificationFingerprints(t, notifier, contact, adminEmail, "valid-token")
mockPurchase.AssertExpectations(t)
mockPurchase.AssertNotCalled(t, "ApproveExecution")
mockPurchase.AssertNotCalled(t, "ApproveExecution", mock.Anything, mock.Anything, mock.Anything, mock.Anything)
}

// TestExecutedNotification_DirectExecutePath is the regression test for the
Expand Down
10 changes: 5 additions & 5 deletions internal/api/handler_analytics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func TestHandler_getHistoryAnalytics_InvalidProvider(t *testing.T) {
_, err := handler.getHistoryAnalytics(ctx, req, map[string]string{"provider": "oracle"})
require.Error(t, err)
assert.Contains(t, err.Error(), "invalid provider")
mockClient.AssertNotCalled(t, "QueryHistory")
mockClient.AssertNotCalled(t, "QueryHistory", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
}

func TestHandler_getHistoryAnalytics_InvalidDateRange(t *testing.T) {
Expand Down Expand Up @@ -256,7 +256,7 @@ func TestHandler_getHistoryAnalytics_ScopedUser_RequiresAccountID(t *testing.T)
_, err := handler.getHistoryAnalytics(ctx, req, map[string]string{})
require.Error(t, err)
assert.Contains(t, err.Error(), "account_id is required")
mockClient.AssertNotCalled(t, "QueryHistory")
mockClient.AssertNotCalled(t, "QueryHistory", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
}

func TestHandler_getHistoryBreakdown_Success(t *testing.T) {
Expand Down Expand Up @@ -411,7 +411,7 @@ func TestHandler_triggerAnalyticsCollection_NonAdmin(t *testing.T) {
_, err := handler.triggerAnalyticsCollection(ctx, req, nil)
require.Error(t, err)
assert.Contains(t, err.Error(), "admin access required")
mockCollector.AssertNotCalled(t, "Collect")
mockCollector.AssertNotCalled(t, "Collect", mock.Anything)
}

func TestParseDateRange(t *testing.T) {
Expand Down Expand Up @@ -636,7 +636,7 @@ func TestHandler_getAnalyticsTrends_ScopedUser_RequiresAccountID(t *testing.T) {
_, err := handler.getAnalyticsTrends(ctx, req, map[string]string{})
require.Error(t, err)
assert.Contains(t, err.Error(), "account_id is required")
mockSnap.AssertNotCalled(t, "QueryMonthlyTotals")
mockSnap.AssertNotCalled(t, "QueryMonthlyTotals", mock.Anything, mock.Anything, mock.Anything, mock.Anything)
}

// TestHandler_getAnalyticsTrends_ScopedUser_OutsideScope returns not-found when
Expand All @@ -659,5 +659,5 @@ func TestHandler_getAnalyticsTrends_ScopedUser_OutsideScope(t *testing.T) {

_, err := handler.getAnalyticsTrends(ctx, req, map[string]string{"account_id": "other-acct"})
require.Error(t, err)
mockSnap.AssertNotCalled(t, "QueryMonthlyTotals")
mockSnap.AssertNotCalled(t, "QueryMonthlyTotals", mock.Anything, mock.Anything, mock.Anything, mock.Anything)
}
2 changes: 1 addition & 1 deletion internal/api/handler_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ func TestHandler_updateProfile_RejectsInvalidEmail(t *testing.T) {
assert.Equal(t, 400, ce.code)
assert.Contains(t, ce.message, "email")
// Confirm UpdateUserProfile was never reached.
mockAuth.AssertNotCalled(t, "UpdateUserProfile")
mockAuth.AssertNotCalled(t, "UpdateUserProfile", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
}

// TestHandler_updateProfile_AcceptsValidEmail verifies that a well-formed
Expand Down
4 changes: 2 additions & 2 deletions internal/api/handler_per_account_perms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func TestPerAccountPerms_HistoryAnalytics_CrossAccountRejected(t *testing.T) {
"cross-account analytics must return 404; got: %v", err)

// The analytics backend must never be called — the scope check fires first.
mockClient.AssertNotCalled(t, "QueryHistory")
mockClient.AssertNotCalled(t, "QueryHistory", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
}

// TestPerAccountPerms_HistoryAnalytics_AllowedAccountSucceeds is the paired
Expand Down Expand Up @@ -463,7 +463,7 @@ func TestPerAccountPerms_HistoryBreakdown_CrossAccountRejected(t *testing.T) {
assert.True(t, IsNotFoundError(err),
"cross-account breakdown must return 404; got: %v", err)

mockClient.AssertNotCalled(t, "QueryBreakdown")
mockClient.AssertNotCalled(t, "QueryBreakdown", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
}

// ─── 6. GET /dashboard/summary ───────────────────────────────────────────────
Expand Down
12 changes: 6 additions & 6 deletions internal/api/handler_purchases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func TestHandler_approvePurchase_RejectsMismatchedSession(t *testing.T) {
// asserts nothing by construction; a .On(...) entry above would create
// a false positive, so we pin the negative by confirming the error is
// the authz error, not an approval-manager error.
mockPurchase.AssertNotCalled(t, "ApproveExecution")
mockPurchase.AssertNotCalled(t, "ApproveExecution", mock.Anything, mock.Anything, mock.Anything, mock.Anything)
}

// TestHandler_approvePurchase_RejectsMissingContactEmail covers the
Expand Down Expand Up @@ -204,7 +204,7 @@ func TestHandler_approvePurchase_RejectsMissingContactEmail(t *testing.T) {
_, err := handler.approvePurchase(ctx, req, execID, "valid-token")
require.Error(t, err)
assert.Contains(t, err.Error(), "no per-account contact email")
mockPurchase.AssertNotCalled(t, "ApproveExecution")
mockPurchase.AssertNotCalled(t, "ApproveExecution", mock.Anything, mock.Anything, mock.Anything, mock.Anything)
}

func TestHandler_approvePurchase_RejectsMissingSession(t *testing.T) {
Expand Down Expand Up @@ -328,7 +328,7 @@ func TestHandler_approvePurchase_SessionApproveAnyChainsToExecute(t *testing.T)
require.NoError(t, err)
assert.Equal(t, "completed", result.(map[string]string)["status"])
mockPurchase.AssertExpectations(t)
mockPurchase.AssertNotCalled(t, "ApproveExecution")
mockPurchase.AssertNotCalled(t, "ApproveExecution", mock.Anything, mock.Anything, mock.Anything, mock.Anything)
}

// TestHandler_approvePurchase_SessionExecuteFailureSurfacesAs409 pins the
Expand Down Expand Up @@ -678,7 +678,7 @@ func TestHandler_approvePurchase_RejectsGlobalNotifyWhenContactSet(t *testing.T)
_, err := handler.approvePurchase(ctx, req, execID, "valid-token")
require.Error(t, err)
assert.Contains(t, err.Error(), "not the authorized approver")
mockPurchase.AssertNotCalled(t, "ApproveExecution")
mockPurchase.AssertNotCalled(t, "ApproveExecution", mock.Anything, mock.Anything, mock.Anything, mock.Anything)
}

// TestHandler_approvePurchase_RejectsCreatorWithoutApprovePermission is the
Expand Down Expand Up @@ -741,8 +741,8 @@ func TestHandler_approvePurchase_RejectsCreatorWithoutApprovePermission(t *testi
require.True(t, ok, "expected a ClientError, got %T: %v", err, err)
assert.Equal(t, 403, ce.code, "creator without approve permission must be denied 403")
// Purchase manager must never be reached.
mockPurchase.AssertNotCalled(t, "ApproveExecution")
mockPurchase.AssertNotCalled(t, "ApproveAndExecute")
mockPurchase.AssertNotCalled(t, "ApproveExecution", mock.Anything, mock.Anything, mock.Anything, mock.Anything)
mockPurchase.AssertNotCalled(t, "ApproveAndExecute", mock.Anything, mock.Anything, mock.Anything, mock.Anything)
}

// TestRouter_approvePurchaseHandler_RateLimited is a regression test for issue #400.
Expand Down
2 changes: 1 addition & 1 deletion internal/api/handler_ri_exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ func TestListExchangeableAzureRIs_SubscriptionIDOutOfScope(t *testing.T) {
// AssertExpectations above passes whether it was called or not; assert it
// explicitly to prove the scope gate refuses the request before the
// tenant-wide listing is ever fetched.
opsClient.AssertNotCalled(t, "ListExchangeableReservations")
opsClient.AssertNotCalled(t, "ListExchangeableReservations", mock.Anything)
}

// TestListExchangeableAzureRIs_SubscriptionIDFiltersToOwnRows exercises
Expand Down
2 changes: 1 addition & 1 deletion internal/auth/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ func TestService_Logout_EmptyToken(t *testing.T) {
assert.Contains(t, err.Error(), "token is required")

// DeleteSession must not be called
mockStore.AssertNotCalled(t, "DeleteSession")
mockStore.AssertNotCalled(t, "DeleteSession", mock.Anything, mock.Anything)
}

func TestService_Logout_NilStore(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions internal/email/mute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestSendPurchaseApprovalRequest_MutedRecipient_NoSESCall(t *testing.T) {
Return(true, nil)
t.Cleanup(func() {
mc.AssertExpectations(t)
ses.AssertNotCalled(t, "SendEmail")
ses.AssertNotCalled(t, "SendEmail", mock.Anything, mock.Anything)
})

s := newSenderWithMute(ses, mc)
Expand Down Expand Up @@ -146,7 +146,7 @@ func TestSendRIExchangePendingApproval_MutedRecipient_NoSESCall(t *testing.T) {
Return(true, nil).Once()
t.Cleanup(func() {
mc.AssertExpectations(t)
ses.AssertNotCalled(t, "SendEmail")
ses.AssertNotCalled(t, "SendEmail", mock.Anything, mock.Anything)
})

s := newSenderWithMute(ses, mc)
Expand Down
8 changes: 7 additions & 1 deletion internal/mocks/assertions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ func TestAssertNotCalled_NameOnlyFormMatchesCallWithArguments(t *testing.T) {
// testify's promoted implementation is the behavior being replaced: it
// still passes, because WithTx never reached mock.Called and because an
// empty expectation cannot match a two-argument call.
assert.True(t, m.Mock.AssertNotCalled(&recordingT{}, "WithTx"))
//
// Hoisted to a local rather than written as m.Mock.AssertNotCalled(...):
// TestNoUnfailableMockAssertions cannot resolve a selector receiver and
// correctly reports such a site for hand review, which this deliberate
// call into the broken implementation would otherwise trip forever.
promoted := &m.Mock
assert.True(t, promoted.AssertNotCalled(&recordingT{}, "WithTx"))
}

// TestAssertNotCalled_WrongMatcherCountFailsLoudly pins the third way these
Expand Down
Loading
Loading