1include!(concat!(env!("OUT_DIR"), "/scopes.rs"));
2
3#[cfg(test)]
4pub(super) mod test {
5 use std::{collections::VecDeque, sync::OnceLock, time::Duration};
6
7 use tokio::sync::mpsc;
8
9 use crate::{
10 executor::{ExecutorExt, ReqwestClient},
11 models::{
12 AttackCode, FactionSelectionName, PersonalStatsCategoryEnum, PersonalStatsStatName,
13 UserListEnum,
14 },
15 };
16
17 use super::*;
18
19 static TICKETS: OnceLock<mpsc::Sender<mpsc::Sender<ReqwestClient>>> = OnceLock::new();
20
21 pub(crate) async fn test_client() -> ReqwestClient {
22 let (tx, mut rx) = mpsc::channel(1);
23
24 let ticket_tx = TICKETS
25 .get_or_init(|| {
26 let (tx, mut rx) = mpsc::channel(1);
27 std::thread::spawn(move || {
28 let mut queue = VecDeque::<mpsc::Sender<ReqwestClient>>::new();
29
30 let rt = tokio::runtime::Builder::new_current_thread()
31 .enable_time()
32 .build()
33 .unwrap();
34
35 rt.block_on(async move {
36 loop {
37 tokio::select! {
38 recv_result = rx.recv() => {
39 match recv_result {
40 Some(ticket) => queue.push_back(ticket),
41 None => break,
42 }
43 }
44 _ = tokio::time::sleep(Duration::from_secs(1)) => {
45 if let Some(next) = queue.pop_front() {
46 next.send(ReqwestClient::new(&std::env::var("API_KEY").unwrap())).await.unwrap()
47 }
48 }
49 }
50 }
51 });
52 });
53
54 tx
55 })
56 .clone();
57
58 ticket_tx.send(tx).await.unwrap();
59
60 rx.recv().await.unwrap()
61 }
62
63 #[tokio::test]
64 async fn faction() {
65 let client = test_client().await;
66
67 let r = client
68 .faction()
69 .for_selections(|b| {
70 b.selections([FactionSelectionName::Basic, FactionSelectionName::Balance])
71 })
72 .await
73 .unwrap();
74
75 r.faction_basic_response().unwrap();
76 }
77
78 #[tokio::test]
79 async fn faction_applications() {
80 let client = test_client().await;
81
82 let faction_scope = FactionScope(&client);
83
84 faction_scope.applications(|b| b).await.unwrap();
85 }
86
87 #[tokio::test]
88 async fn faction_attacks() {
89 let client = test_client().await;
90
91 let faction_scope = FactionScope(&client);
92
93 faction_scope.attacks(|b| b).await.unwrap();
94 }
95
96 #[tokio::test]
97 async fn faction_attacksfull() {
98 let client = test_client().await;
99
100 let faction_scope = FactionScope(&client);
101
102 faction_scope.attacksfull(|b| b).await.unwrap();
103 }
104
105 #[tokio::test]
106 async fn faction_balance() {
107 let client = test_client().await;
108
109 let faction_scope = FactionScope(&client);
110
111 faction_scope.balance(|b| b).await.unwrap();
112 }
113
114 #[tokio::test]
115 async fn faction_basic() {
116 let client = test_client().await;
117
118 let faction_scope = FactionScope(&client);
119
120 faction_scope.basic(|b| b).await.unwrap();
121 }
122
123 #[tokio::test]
124 async fn faction_basic_for_id() {
125 let client = test_client().await;
126
127 let faction_scope = FactionScope(&client);
128
129 faction_scope.basic_for_id(19.into(), |b| b).await.unwrap();
130 }
131
132 #[tokio::test]
133 async fn faction_chain() {
134 let client = test_client().await;
135
136 let faction_scope = FactionScope(&client);
137
138 faction_scope.chain(|b| b).await.unwrap();
139 }
140
141 #[tokio::test]
142 async fn faction_chain_for_id() {
143 let client = test_client().await;
144
145 let faction_scope = FactionScope(&client);
146
147 faction_scope.chain_for_id(19.into(), |b| b).await.unwrap();
148 }
149
150 #[tokio::test]
151 async fn faction_chains() {
152 let client = test_client().await;
153
154 let faction_scope = FactionScope(&client);
155
156 faction_scope.chains(|b| b).await.unwrap();
157 }
158
159 #[tokio::test]
160 async fn factions_chains_for_id() {
161 let client = test_client().await;
162
163 let faction_scope = FactionScope(&client);
164
165 faction_scope.chains_for_id(19.into(), |b| b).await.unwrap();
166 }
167
168 #[tokio::test]
169 async fn faction_chain_report() {
170 let client = test_client().await;
171
172 let faction_scope = FactionScope(&client);
173
174 faction_scope.chainreport(|b| b).await.unwrap();
175 }
176
177 #[tokio::test]
178 async fn faction_chain_report_for_id() {
179 let client = test_client().await;
180
181 let faction_scope = FactionScope(&client);
182
183 faction_scope
184 .chainreport_for_chain_id(47004769.into(), |b| b)
185 .await
186 .unwrap();
187 }
188
189 #[tokio::test]
190 async fn faction_contributors() {
191 let client = test_client().await;
192
193 let faction_scope = FactionScope(&client);
194
195 faction_scope
196 .contributors(|b| b.stat(crate::models::FactionStatEnum::Revives))
197 .await
198 .unwrap();
199 }
200
201 #[tokio::test]
202 async fn faction_crimes() {
203 let client = test_client().await;
204
205 let faction_scope = FactionScope(&client);
206
207 faction_scope.crimes(|b| b).await.unwrap();
208 }
209
210 #[tokio::test]
211 async fn faction_crime_for_id() {
212 let client = test_client().await;
213
214 let faction_scope = FactionScope(&client);
215
216 faction_scope
217 .crime_for_crime_id(468347.into(), |b| b)
218 .await
219 .unwrap();
220 }
221
222 #[tokio::test]
223 async fn faction_hof() {
224 let client = test_client().await;
225
226 let faction_scope = FactionScope(&client);
227
228 faction_scope.hof(|b| b).await.unwrap();
229 }
230
231 #[tokio::test]
232 async fn faction_hof_for_id() {
233 let client = test_client().await;
234
235 let faction_scope = FactionScope(&client);
236
237 faction_scope.hof_for_id(19.into(), |b| b).await.unwrap();
238 }
239
240 #[tokio::test]
241 async fn faction_members() {
242 let client = test_client().await;
243
244 let faction_scope = FactionScope(&client);
245
246 faction_scope.members(|b| b).await.unwrap();
247 }
248
249 #[tokio::test]
250 async fn faction_members_for_id() {
251 let client = test_client().await;
252
253 let faction_scope = FactionScope(&client);
254
255 faction_scope
256 .members_for_id(19.into(), |b| b)
257 .await
258 .unwrap();
259 }
260
261 #[tokio::test]
262 async fn faction_news() {
263 let client = test_client().await;
264
265 let faction_scope = FactionScope(&client);
266
267 faction_scope
268 .news(|b| b.cat(crate::models::FactionNewsCategory::Attack))
269 .await
270 .unwrap();
271 }
272
273 #[tokio::test]
274 async fn faction_ranked_wars() {
275 let client = test_client().await;
276
277 let faction_scope = FactionScope(&client);
278
279 faction_scope.rankedwars(|b| b).await.unwrap();
280 }
281
282 #[tokio::test]
283 async fn faction_ranked_war_for_id() {
284 let client = test_client().await;
285
286 let faction_scope = FactionScope(&client);
287
288 faction_scope
289 .rankedwars_for_id(19.into(), |b| b)
290 .await
291 .unwrap();
292 }
293
294 #[tokio::test]
295 async fn faction_ranked_war_report_for_id() {
296 let client = test_client().await;
297
298 let faction_scope = FactionScope(&client);
299
300 faction_scope
301 .rankedwarreport_for_ranked_war_id(24424.into(), |b| b)
302 .await
303 .unwrap();
304 }
305
306 #[tokio::test]
307 async fn faction_revives() {
308 let client = test_client().await;
309
310 let faction_scope = FactionScope(&client);
311
312 faction_scope.revives(|b| b).await.unwrap();
313 }
314
315 #[tokio::test]
316 async fn faction_revives_full() {
317 let client = test_client().await;
318
319 let faction_scope = FactionScope(&client);
320
321 faction_scope.revives_full(|b| b).await.unwrap();
322 }
323
324 #[tokio::test]
325 async fn faction_stats() {
326 let client = test_client().await;
327
328 let faction_scope = FactionScope(&client);
329
330 faction_scope.stats(|b| b).await.unwrap();
331 }
332
333 #[tokio::test]
334 async fn faction_upgrades() {
335 let client = test_client().await;
336
337 let faction_scope = FactionScope(&client);
338
339 faction_scope.upgrades(|b| b).await.unwrap();
340 }
341
342 #[tokio::test]
343 async fn faction_wars() {
344 let client = test_client().await;
345
346 let faction_scope = FactionScope(&client);
347
348 faction_scope.wars(|b| b).await.unwrap();
349 }
350
351 #[tokio::test]
352 async fn faction_wars_for_id() {
353 let client = test_client().await;
354
355 let faction_scope = FactionScope(&client);
356
357 faction_scope.wars_for_id(19.into(), |b| b).await.unwrap();
358 }
359
360 #[tokio::test]
361 async fn faction_lookup() {
362 let client = test_client().await;
363
364 let faction_scope = FactionScope(&client);
365
366 faction_scope.lookup(|b| b).await.unwrap();
367 }
368
369 #[tokio::test]
370 async fn faction_reports() {
371 let client = test_client().await;
372
373 let faction_scope = FactionScope(&client);
374
375 faction_scope.reports(|b| b).await.unwrap();
376 }
377
378 #[tokio::test]
379 async fn forum_categories() {
380 let client = test_client().await;
381
382 let forum_scope = ForumScope(&client);
383
384 forum_scope.categories(|b| b).await.unwrap();
385 }
386
387 #[tokio::test]
388 async fn forum_posts_for_thread_id() {
389 let client = test_client().await;
390
391 let forum_scope = ForumScope(&client);
392
393 forum_scope
394 .posts_for_thread_id(16129703.into(), |b| b)
395 .await
396 .unwrap();
397 }
398
399 #[tokio::test]
400 async fn forum_thread_for_thread_id() {
401 let client = test_client().await;
402
403 let forum_scope = ForumScope(&client);
404
405 forum_scope
406 .thread_for_thread_id(16129703.into(), |b| b)
407 .await
408 .unwrap();
409 }
410
411 #[tokio::test]
412 async fn forum_threads() {
413 let client = test_client().await;
414
415 let forum_scope = ForumScope(&client);
416
417 forum_scope.threads(|b| b).await.unwrap();
418 }
419
420 #[tokio::test]
421 async fn forum_threads_for_category_ids() {
422 let client = test_client().await;
423
424 let forum_scope = ForumScope(&client);
425
426 forum_scope
427 .threads_for_category_ids([2.into()].into(), |b| b)
428 .await
429 .unwrap();
430 }
431
432 #[tokio::test]
433 async fn forum_lookup() {
434 let client = test_client().await;
435
436 let forum_scope = ForumScope(&client);
437
438 forum_scope.lookup(|b| b).await.unwrap();
439 }
440
441 #[tokio::test]
442 async fn forum_timestamp() {
443 let client = test_client().await;
444
445 let forum_scope = ForumScope(&client);
446
447 forum_scope.timestamp(|b| b).await.unwrap();
448 }
449
450 #[tokio::test]
451 async fn market_itemmarket_for_id() {
452 let client = test_client().await;
453
454 let market_scope = MarketScope(&client);
455
456 market_scope
457 .itemmarket_for_id(1.into(), |b| b)
458 .await
459 .unwrap();
460 }
461
462 #[tokio::test]
463 async fn market_lookup() {
464 let client = test_client().await;
465
466 let market_scope = MarketScope(&client);
467
468 market_scope.lookup(|b| b).await.unwrap();
469 }
470
471 #[tokio::test]
472 async fn market_timestamp() {
473 let client = test_client().await;
474
475 let market_scope = MarketScope(&client);
476
477 market_scope.timestamp(|b| b).await.unwrap();
478 }
479
480 #[tokio::test]
481 async fn racing_cars() {
482 let client = test_client().await;
483
484 let racing_scope = RacingScope(&client);
485
486 racing_scope.cars(|b| b).await.unwrap();
487 }
488
489 #[tokio::test]
490 async fn racing_carupgrades() {
491 let client = test_client().await;
492
493 let racing_scope = RacingScope(&client);
494
495 racing_scope.carupgrades(|b| b).await.unwrap();
496 }
497
498 #[tokio::test]
499 async fn racing_races() {
500 let client = test_client().await;
501
502 let racing_scope = RacingScope(&client);
503
504 racing_scope.races(|b| b).await.unwrap();
505 }
506
507 #[tokio::test]
508 async fn racing_race_for_race_id() {
509 let client = test_client().await;
510
511 let racing_scope = RacingScope(&client);
512
513 racing_scope
514 .race_for_race_id(14650821.into(), |b| b)
515 .await
516 .unwrap();
517 }
518
519 #[tokio::test]
520 async fn racing_tracks() {
521 let client = test_client().await;
522
523 let racing_scope = RacingScope(&client);
524
525 racing_scope.tracks(|b| b).await.unwrap();
526 }
527
528 #[tokio::test]
529 async fn racing_lookup() {
530 let client = test_client().await;
531
532 let racing_scope = RacingScope(&client);
533
534 racing_scope.lookup(|b| b).await.unwrap();
535 }
536
537 #[tokio::test]
538 async fn racing_timestamp() {
539 let client = test_client().await;
540
541 let racing_scope = RacingScope(&client);
542
543 racing_scope.timestamp(|b| b).await.unwrap();
544 }
545
546 #[tokio::test]
547 async fn torn_attacklog() {
548 let client = test_client().await;
549
550 let racing_scope = TornScope(&client);
551
552 racing_scope
553 .attacklog(|b| b.log(AttackCode("ec987a60a22155cbfb7c1625cbb2092f".to_owned())))
554 .await
555 .unwrap();
556 }
557
558 #[tokio::test]
559 async fn torn_bounties() {
560 let client = test_client().await;
561
562 let torn_scope = TornScope(&client);
563
564 torn_scope.bounties(|b| b).await.unwrap();
565 }
566
567 #[tokio::test]
568 async fn torn_calendar() {
569 let client = test_client().await;
570
571 let torn_scope = TornScope(&client);
572
573 torn_scope.calendar(|b| b).await.unwrap();
574 }
575
576 #[tokio::test]
577 async fn torn_crimes() {
578 let client = test_client().await;
579
580 let torn_scope = TornScope(&client);
581
582 torn_scope.crimes(|b| b).await.unwrap();
583 }
584
585 #[tokio::test]
586 async fn torn_factionhof() {
587 let client = test_client().await;
588
589 let torn_scope = TornScope(&client);
590
591 torn_scope
592 .factionhof(|b| b.cat(crate::models::TornFactionHofCategory::Rank))
593 .await
594 .unwrap();
595 }
596
597 #[tokio::test]
598 async fn torn_factiontree() {
599 let client = test_client().await;
600
601 let torn_scope = TornScope(&client);
602
603 torn_scope.factiontree(|b| b).await.unwrap();
604 }
605
606 #[tokio::test]
607 async fn torn_hof() {
608 let client = test_client().await;
609
610 let torn_scope = TornScope(&client);
611
612 torn_scope
613 .hof(|b| b.cat(crate::models::TornHofCategory::Offences))
614 .await
615 .unwrap();
616 }
617
618 #[tokio::test]
619 async fn torn_itemammo() {
620 let client = test_client().await;
621
622 let torn_scope = TornScope(&client);
623
624 torn_scope.itemammo(|b| b).await.unwrap();
625 }
626
627 #[tokio::test]
628 async fn torn_itemmods() {
629 let client = test_client().await;
630
631 let torn_scope = TornScope(&client);
632
633 torn_scope.itemmods(|b| b).await.unwrap();
634 }
635
636 #[tokio::test]
637 async fn torn_items() {
638 let client = test_client().await;
639
640 let torn_scope = TornScope(&client);
641
642 torn_scope.items(|b| b).await.unwrap();
643 }
644
645 #[tokio::test]
646 async fn torn_items_for_ids() {
647 let client = test_client().await;
648
649 let torn_scope = TornScope(&client);
650
651 torn_scope
652 .items_for_ids([1.into()].into(), |b| b)
653 .await
654 .unwrap();
655 }
656
657 #[tokio::test]
658 async fn torn_logcategories() {
659 let client = test_client().await;
660
661 let torn_scope = TornScope(&client);
662
663 torn_scope.logcategories(|b| b).await.unwrap();
664 }
665
666 #[tokio::test]
667 async fn torn_logtypes() {
668 let client = test_client().await;
669
670 let torn_scope = TornScope(&client);
671
672 torn_scope.logtypes(|b| b).await.unwrap();
673 }
674
675 #[tokio::test]
676 async fn torn_logtypes_for_log_category_id() {
677 let client = test_client().await;
678
679 let torn_scope = TornScope(&client);
680
681 torn_scope
682 .logtypes_for_log_category_id(23.into(), |b| b)
683 .await
684 .unwrap();
685 }
686
687 #[tokio::test]
688 async fn torn_subrcimes_for_crime_id() {
689 let client = test_client().await;
690
691 let torn_scope = TornScope(&client);
692
693 torn_scope
694 .subcrimes_for_crime_id(3.into(), |b| b)
695 .await
696 .unwrap();
697 }
698
699 #[tokio::test]
700 async fn torn_lookup() {
701 let client = test_client().await;
702 let torn_scope = TornScope(&client);
703
704 torn_scope.lookup(|b| b).await.unwrap();
705 }
706
707 #[tokio::test]
708 async fn torn_timestamp() {
709 let client = test_client().await;
710
711 let torn_scope = TornScope(&client);
712
713 torn_scope.timestamp(|b| b).await.unwrap();
714 }
715
716 #[tokio::test]
717 async fn user_attacks() {
718 let client = test_client().await;
719
720 client.user().attacks(|b| b).await.unwrap();
721 }
722
723 #[tokio::test]
724 async fn user_attacksfull() {
725 let client = test_client().await;
726
727 client.user().attacksfull(|b| b).await.unwrap();
728 }
729
730 #[tokio::test]
731 async fn user_bounties() {
732 let client = test_client().await;
733
734 client.user().bounties(|b| b).await.unwrap();
735 }
736
737 #[tokio::test]
738 async fn user_bounties_for_id() {
739 let client = test_client().await;
740
741 client
742 .user()
743 .bounties_for_id(986228.into(), |b| b)
744 .await
745 .unwrap();
746 }
747
748 #[tokio::test]
749 async fn user_calendar() {
750 let client = test_client().await;
751
752 client.user().calendar(|b| b).await.unwrap();
753 }
754
755 #[tokio::test]
756 async fn user_crimes_for_crime_id() {
757 let client = test_client().await;
758
759 client
760 .user()
761 .crimes_for_crime_id(10.into(), |b| b)
762 .await
763 .unwrap();
764 }
765
766 #[tokio::test]
767 async fn user_enlisted_cars() {
768 let client = test_client().await;
769
770 client.user().enlistedcars(|b| b).await.unwrap();
771 }
772
773 #[tokio::test]
774 async fn user_factionbalance() {
775 let client = test_client().await;
776
777 client.user().factionbalance(|b| b).await.unwrap();
778 }
779
780 #[tokio::test]
781 async fn user_forumfeed() {
782 let client = test_client().await;
783
784 client.user().forumfeed(|b| b).await.unwrap();
785 }
786
787 #[tokio::test]
788 async fn user_forumfriends() {
789 let client = test_client().await;
790
791 client.user().forumfriends(|b| b).await.unwrap();
792 }
793
794 #[tokio::test]
795 async fn user_forumposts() {
796 let client = test_client().await;
797
798 client.user().forumposts(|b| b).await.unwrap();
799 }
800
801 #[tokio::test]
802 async fn user_forumposts_for_id() {
803 let client = test_client().await;
804
805 client
806 .user()
807 .forumposts_for_id(1.into(), |b| b)
808 .await
809 .unwrap();
810 }
811
812 #[tokio::test]
813 async fn user_forumsubscribedthreads() {
814 let client = test_client().await;
815
816 client.user().forumsubscribedthreads(|b| b).await.unwrap();
817 }
818
819 #[tokio::test]
820 async fn user_forumthreads() {
821 let client = test_client().await;
822
823 client.user().forumthreads(|b| b).await.unwrap();
824 }
825
826 #[tokio::test]
827 async fn user_forumthreads_for_id() {
828 let client = test_client().await;
829
830 client
831 .user()
832 .forumthreads_for_id(1.into(), |b| b)
833 .await
834 .unwrap();
835 }
836
837 #[tokio::test]
838 async fn user_hof() {
839 let client = test_client().await;
840
841 client.user().hof(|b| b).await.unwrap();
842 }
843
844 #[tokio::test]
845 async fn user_hof_for_id() {
846 let client = test_client().await;
847
848 client.user().hof_for_id(1.into(), |b| b).await.unwrap();
849 }
850
851 #[tokio::test]
852 async fn user_itemmarket() {
853 let client = test_client().await;
854
855 client.user().itemmarket(|b| b).await.unwrap();
856 }
857
858 #[tokio::test]
859 async fn user_jobranks() {
860 let client = test_client().await;
861
862 client.user().jobranks(|b| b).await.unwrap();
863 }
864
865 #[tokio::test]
866 async fn user_list() {
867 let client = test_client().await;
868
869 client
870 .user()
871 .list(|b| b.cat(UserListEnum::Friends))
872 .await
873 .unwrap();
874 }
875
876 #[tokio::test]
877 async fn user_organizedcrime() {
878 let client = test_client().await;
879
880 client.user().organizedcrime(|b| b).await.unwrap();
881 }
882
883 #[tokio::test]
884 async fn user_personalstats() {
885 let client = test_client().await;
886
887 client
888 .user()
889 .personalstats(|b| {
890 b.stat([PersonalStatsStatName::Piercinghits])
891 .timestamp(1737661955)
892 })
893 .await
894 .unwrap();
895
896 client
897 .user()
898 .personalstats(|b| b.cat(PersonalStatsCategoryEnum::All))
899 .await
900 .unwrap();
901
902 client
903 .user()
904 .personalstats(|b| b.cat(PersonalStatsCategoryEnum::Popular))
905 .await
906 .unwrap();
907
908 client
909 .user()
910 .personalstats(|b| b.cat(PersonalStatsCategoryEnum::Drugs))
911 .await
912 .unwrap();
913
914 client
915 .user()
916 .personalstats(|b| b.stat([PersonalStatsStatName::Piercinghits]))
917 .await
918 .unwrap();
919 }
920
921 #[tokio::test]
922 async fn user_personalstats_for_id() {
923 let client = test_client().await;
924
925 client
926 .user()
927 .personalstats_for_id(1.into(), |b| b.cat(PersonalStatsCategoryEnum::All))
928 .await
929 .unwrap();
930 }
931
932 #[tokio::test]
933 async fn user_races() {
934 let client = test_client().await;
935
936 client.user().races(|b| b).await.unwrap();
937 }
938
939 #[tokio::test]
940 async fn user_revives() {
941 let client = test_client().await;
942
943 client.user().revives(|b| b).await.unwrap();
944 }
945
946 #[tokio::test]
947 async fn user_revivesfull() {
948 let client = test_client().await;
949
950 client.user().revives_full(|b| b).await.unwrap();
951 }
952
953 #[tokio::test]
954 async fn user_lookup() {
955 let client = test_client().await;
956
957 client.user().lookup(|b| b).await.unwrap();
958 }
959
960 #[tokio::test]
961 async fn user_timestamp() {
962 let client = test_client().await;
963
964 client.user().attacks(|b| b).await.unwrap();
965 }
966
967 #[tokio::test]
968 async fn user_reports() {
969 let client = test_client().await;
970
971 client.user().reports(|b| b).await.unwrap();
972 }
973}