TestTrackUsage_ZeroCostNoOp verifies that a zero-cost failed completion (e.g., the provider never returned a usage chunk) writes nothing.
(t *testing.T)
| 118 | // TestTrackUsage_ZeroCostNoOp verifies that a zero-cost failed completion |
| 119 | // (e.g., the provider never returned a usage chunk) writes nothing. |
| 120 | func 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 | } |
nothing calls this directly
no test coverage detected