Skip to content

Commit 228a5a1

Browse files
authored
Merge pull request #532 from AmbireTech/additional-analytics-tests
Adding multiple events in a single update test case
2 parents 3921688 + 5e718fe commit 228a5a1

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

sentry/src/db/analytics.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,32 @@ mod test {
229229
assert_eq!(UnifiedNum::from_u64(1_000_000), analytics.payout_amount);
230230
assert_eq!(1, analytics.payout_count);
231231

232-
let analytics_updated = update_analytics(&database.clone(), update.clone())
232+
let new_update = UpdateAnalytics {
233+
time: DateHour::from_ymdh(2021, 2, 1, 1),
234+
campaign_id: DUMMY_CAMPAIGN.id,
235+
ad_unit: ad_unit.ipfs,
236+
ad_slot: ad_slot_ipfs,
237+
ad_slot_type: Some(ad_unit.ad_type.clone()),
238+
advertiser: *CREATOR,
239+
publisher: *PUBLISHER,
240+
hostname: Some("localhost".to_string()),
241+
country: Some("Bulgaria".to_string()),
242+
os_name: OperatingSystem::Linux,
243+
chain_id: ChainId::new(1),
244+
event_type: IMPRESSION,
245+
amount_to_add: UnifiedNum::from_u64(1_000_000),
246+
count_to_add: 69,
247+
};
248+
249+
let analytics_updated = update_analytics(&database.clone(), new_update.clone())
233250
.await
234251
.expect("Should update");
252+
235253
assert_eq!(
236254
analytics_updated.payout_amount,
237255
UnifiedNum::from_u64(2_000_000)
238256
);
239-
assert_eq!(analytics_updated.payout_count, 2);
257+
assert_eq!(analytics_updated.payout_count, 70);
240258
}
241259

242260
// On empty fields marked as `NOT NULL` it should successfully insert a new analytics

0 commit comments

Comments
 (0)