MCPcopy Create free account
hub / github.com/PaperDebugger/paperdebugger / TestTrackUsage_ZeroCostNoOp

Function TestTrackUsage_ZeroCostNoOp

internal/services/usage_test.go:120–136  ·  view source on GitHub ↗

TestTrackUsage_ZeroCostNoOp verifies that a zero-cost failed completion (e.g., the provider never returned a usage chunk) writes nothing.

(t *testing.T)

Source from the content-addressed store, hash-verified

118// TestTrackUsage_ZeroCostNoOp verifies that a zero-cost failed completion
119// (e.g., the provider never returned a usage chunk) writes nothing.
120func TestTrackUsage_ZeroCostNoOp(t *testing.T) {
121 us, database := setupTestUsageService(t)
122 ctx := context.Background()
123
124 userID := bson.NewObjectID()
125 projectID := "test-project-" + bson.NewObjectID().Hex()
126
127 err := us.TrackUsage(ctx, userID, projectID, 0, false)
128 assert.NoError(t, err)
129
130 count, err := database.Collection(models.LifetimeUsage{}.CollectionName()).CountDocuments(ctx, bson.M{
131 "user_id": userID,
132 "project_id": projectID,
133 })
134 assert.NoError(t, err)
135 assert.Equal(t, int64(0), count)
136}

Callers

nothing calls this directly

Calls 3

setupTestUsageServiceFunction · 0.85
TrackUsageMethod · 0.80
CollectionNameMethod · 0.65

Tested by

no test coverage detected