|
| 1 | +#![allow(unused_variables)] |
| 2 | +mod common; |
| 3 | +use common::*; |
| 4 | + |
| 5 | +use spa_server::config::get_host_path_from_domain; |
| 6 | +use std::time::Duration; |
| 7 | + |
| 8 | +#[tokio::test(flavor = "multi_thread", worker_threads = 3)] |
| 9 | +async fn test_wrong_token() { |
| 10 | + let domain = LOCAL_HOST.to_owned() + "/27"; |
| 11 | + let domain = &domain; |
| 12 | + |
| 13 | + clean_web_domain_dir(LOCAL_HOST); |
| 14 | + |
| 15 | + let server_handle = run_server(); |
| 16 | + |
| 17 | + tokio::time::sleep(Duration::from_secs(1)).await; |
| 18 | + |
| 19 | + let (api, _) = get_client_api("client_config_wrong_token.toml"); |
| 20 | + let result = api |
| 21 | + .get_domain_info(Some(get_host_path_from_domain(domain).0.to_string())) |
| 22 | + .await; |
| 23 | + assert!(result.is_err()); |
| 24 | + server_handle.abort(); |
| 25 | +} |
| 26 | + |
| 27 | +#[tokio::test(flavor = "multi_thread", worker_threads = 3)] |
| 28 | +async fn test_remove_last_version_and_domain() { |
| 29 | + let domain = LOCAL_HOST.to_owned() + "/27"; |
| 30 | + let domain = &domain; |
| 31 | + let request_prefix = format!("http://{LOCAL_HOST}:8080/27"); |
| 32 | + let request_prefix = &request_prefix; |
| 33 | + |
| 34 | + clean_web_domain_dir(LOCAL_HOST); |
| 35 | + |
| 36 | + let server_handle = run_server(); |
| 37 | + |
| 38 | + tokio::time::sleep(Duration::from_secs(1)).await; |
| 39 | + |
| 40 | + upload_file_and_check(domain, request_prefix, 1, vec![]).await; |
| 41 | + |
| 42 | + let (api, _) = get_client_api("client_config.toml"); |
| 43 | + api.remove_files(Some(domain.to_string()), Some(1)) |
| 44 | + .await |
| 45 | + .unwrap(); |
| 46 | + |
| 47 | + let result = api |
| 48 | + .get_domain_info(Some(get_host_path_from_domain(domain).0.to_string())) |
| 49 | + .await; |
| 50 | + assert!(result.is_ok()); |
| 51 | + assert!(result.unwrap().is_empty()); |
| 52 | + server_handle.abort(); |
| 53 | +} |
0 commit comments