@@ -401,6 +401,106 @@ TEST_F(PublisherInfoDatabaseTest, InsertOrUpdateRecurringDonation) {
401
401
EXPECT_FALSE (info_sql_2.Step ());
402
402
}
403
403
404
+ TEST_F (PublisherInfoDatabaseTest, GetPanelPublisher) {
405
+ base::ScopedTempDir temp_dir;
406
+ base::FilePath db_file;
407
+ CreateTempDatabase (&temp_dir, &db_file);
408
+
409
+ /* *
410
+ * Publisher ID is missing
411
+ */
412
+ ledger::ActivityInfoFilter filter_1;
413
+ EXPECT_EQ (publisher_info_database_->GetPanelPublisher (filter_1), nullptr );
414
+
415
+ /* *
416
+ * Empty table
417
+ */
418
+ ledger::ActivityInfoFilter filter_2;
419
+ filter_2.id = " test" ;
420
+ EXPECT_EQ (publisher_info_database_->GetPanelPublisher (filter_2), nullptr );
421
+
422
+ /* *
423
+ * Ignore month and year filter
424
+ */
425
+ ledger::PublisherInfo info_1;
426
+ info_1.id = " brave.com" ;
427
+ info_1.url = " https://brave.com" ;
428
+ info_1.percent = 11 ;
429
+ info_1.month = ledger::ACTIVITY_MONTH::JANUARY;
430
+ info_1.year = 2019 ;
431
+ info_1.reconcile_stamp = 10 ;
432
+
433
+ bool success = publisher_info_database_->InsertOrUpdateActivityInfo (info_1);
434
+ EXPECT_TRUE (success);
435
+
436
+ ledger::ActivityInfoFilter filter_3;
437
+ filter_3.id = " brave.com" ;
438
+ filter_3.month = ledger::ACTIVITY_MONTH::ANY;
439
+ filter_3.year = -1 ;
440
+ filter_3.reconcile_stamp = 10 ;
441
+ std::unique_ptr<ledger::PublisherInfo> result =
442
+ publisher_info_database_->GetPanelPublisher (filter_3);
443
+ EXPECT_TRUE (result);
444
+ EXPECT_EQ (result->id , " brave.com" );
445
+ }
446
+
447
+ TEST_F (PublisherInfoDatabaseTest, InsertOrUpdateActivityInfos) {
448
+ base::ScopedTempDir temp_dir;
449
+ base::FilePath db_file;
450
+ CreateTempDatabase (&temp_dir, &db_file);
451
+
452
+ /* *
453
+ * Good path
454
+ */
455
+ ledger::PublisherInfo info_1;
456
+ info_1.id = " brave.com" ;
457
+ info_1.url = " https://brave.com" ;
458
+ info_1.percent = 11 ;
459
+ info_1.month = ledger::ACTIVITY_MONTH::JANUARY;
460
+ info_1.year = 2019 ;
461
+ info_1.reconcile_stamp = 10 ;
462
+
463
+ ledger::PublisherInfo info_2;
464
+ info_2.id = " clifton.io" ;
465
+ info_2.url = " https://clifton.io" ;
466
+ info_2.percent = 11 ;
467
+ info_2.month = ledger::ACTIVITY_MONTH::JANUARY;
468
+ info_2.year = 2019 ;
469
+ info_2.reconcile_stamp = 10 ;
470
+
471
+ ledger::PublisherInfoList list;
472
+ list.push_back (info_1);
473
+ list.push_back (info_2);
474
+
475
+ bool success = publisher_info_database_->InsertOrUpdateActivityInfos (list);
476
+ EXPECT_TRUE (success);
477
+
478
+ /* *
479
+ * Empty list
480
+ */
481
+ ledger::PublisherInfoList list_empty;
482
+
483
+ success = publisher_info_database_->InsertOrUpdateActivityInfos (list_empty);
484
+ EXPECT_FALSE (success);
485
+
486
+ /* *
487
+ * One publisher has empty ID
488
+ */
489
+
490
+ ledger::PublisherInfo info_3;
491
+ info_3.id = " " ;
492
+ info_3.url = " https://page.io" ;
493
+ info_3.percent = 11 ;
494
+ info_3.month = ledger::ACTIVITY_MONTH::JANUARY;
495
+ info_3.year = 2019 ;
496
+ info_3.reconcile_stamp = 10 ;
497
+
498
+ list.push_back (info_3);
499
+
500
+ success = publisher_info_database_->InsertOrUpdateActivityInfos (list);
501
+ EXPECT_FALSE (success);
502
+ }
503
+
404
504
TEST_F (PublisherInfoDatabaseTest, InsertPendingContribution) {
405
505
406
506
}
0 commit comments