-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtests.rs
43 lines (38 loc) · 1.36 KB
/
tests.rs
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
#[cfg(test)]
mod tests {
use crate::updater::get_latest_cli_version;
use crate::utils::minify_lua;
use std::fs;
#[test]
fn test_update() {
let version = String::from("v0.1.10");
assert!(crate::updater::need_update(version).unwrap());
}
#[test]
fn test_mods_fetch() {
let mods = crate::mods::fetch_mods().unwrap();
assert!(mods.len() > 0);
}
#[test]
fn test_parsing() {
let lua_file = fs::read_to_string("test.lua").unwrap();
let functions = crate::utils::extract_functions(lua_file.clone());
assert_eq!(functions.len(), 1);
functions.get("test").unwrap();
assert_eq!(
minify_lua(lua_file),
r#"function test() print("Hello World!") a = function() print("Hello World!") end a() end test()"#
);
}
#[test]
fn test_get_last_cli_version() {
println!("Latest CLI version: {}", get_latest_cli_version());
}
// TODO: Add test for sorted_mods
// {"id": "test", "load_before": ["foo"], "load_after": ["baz", "qux"]}
// {"id": "foo", "load_before": [], "load_after": ["baz", "qux"]}
// {"id": "bar", "load_before": ["baz"], "load_after": []}
// {"id": "baz", "load_before": ["qux"], "load_after": []}
// {"id": "qux", "load_before": [], "load_after": []}
// Expected order: bar, baz, qux, test, foo
}