1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// SPDX-FileCopyrightText: 2022 Robin Vobruba <hoijui.quaero@gmail.com>
// SPDX-FileCopyrightText: 2020 Armin Becher <becherarmin@gmail.com>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
// #[cfg(test)]
// mod helper;
// use helper::benches_dir;
// use mle::markup::MarkupType;
// use mle::Config;
// use mle::{logger, State};
// use std::time::{Duration, Instant};
// const TEST_THROTTLE_MS: u32 = 100;
// const TEST_URLS: u32 = 10;
// const THROTTLED_TIME_MS: u64 = (TEST_THROTTLE_MS as u64) * ((TEST_URLS as u64) - 1);
// #[tokio::test]
// async fn throttle_different_hosts() {
// let test_file = benches_dir().join("throttle").join("different_host.md");
// let config = Config {
// folder: test_file,
// log_level: logger::LogLevel::Debug,
// markup_types: vec![MarkupType::Markdown],
// no_web_links: false,
// no_web_anchors: false,
// match_file_extension: false,
// throttle: TEST_THROTTLE_MS,
// ignore_links: vec![],
// ignore_paths: vec![],
// root_dir: None,
// };
// let mut state = State::new(config);
// let start = Instant::now();
// mle::run(&mut state).await.unwrap_or(());
// let duration = start.elapsed();
// assert!(duration < Duration::from_millis(THROTTLED_TIME_MS))
// }
// #[tokio::test]
// async fn throttle_same_hosts() {
// let test_file = benches_dir().join("throttle").join("same_host.md");
// let config = Config {
// folder: test_file,
// log_level: logger::LogLevel::Debug,
// markup_types: vec![MarkupType::Markdown],
// no_web_links: false,
// no_web_anchors: false,
// match_file_extension: false,
// throttle: TEST_THROTTLE_MS,
// ignore_links: vec![],
// ignore_paths: vec![],
// root_dir: None,
// };
// let mut state = State::new(config);
// let start = Instant::now();
// mle::run(&mut state).await.unwrap_or(());
// let duration = start.elapsed();
// assert!(duration > Duration::from_millis(THROTTLED_TIME_MS))
// }
// #[tokio::test]
// async fn throttle_same_ip() {
// let test_file = benches_dir().join("throttle").join("same_ip.md");
// let config = Config {
// folder: test_file,
// log_level: logger::LogLevel::Debug,
// markup_types: vec![MarkupType::Markdown],
// no_web_links: false,
// no_web_anchors: false,
// match_file_extension: false,
// throttle: TEST_THROTTLE_MS,
// ignore_links: vec![],
// ignore_paths: vec![],
// root_dir: None,
// };
// let mut state = State::new(config);
// let start = Instant::now();
// mle::run(&mut state).await.unwrap_or(());
// let duration = start.elapsed();
// assert!(duration > Duration::from_millis(THROTTLED_TIME_MS))
// }