|
| 1 | +//! Tests for the core commands using the actual TMC API |
| 2 | +
|
| 3 | +use dotenv::dotenv; |
| 4 | +use std::env; |
| 5 | +use std::io::Write; |
| 6 | +use std::process::{Command, Output, Stdio}; |
| 7 | +use tmc_langs_core::*; |
| 8 | + |
| 9 | +fn init() { |
| 10 | + dotenv().ok(); |
| 11 | + if env::var("RUST_LOG").is_err() { |
| 12 | + env::set_var( |
| 13 | + "RUST_LOG", |
| 14 | + "debug,hyper=warn,tokio_reactor=warn,reqwest=warn", |
| 15 | + ); |
| 16 | + } |
| 17 | + let _ = env_logger::builder().is_test(true).try_init(); |
| 18 | +} |
| 19 | + |
| 20 | +fn run_core_cmd(args: &[&str]) -> Output { |
| 21 | + let email = env::var("EMAIL").unwrap(); |
| 22 | + let password = env::var("PASSWORD").unwrap(); |
| 23 | + |
| 24 | + let path = env!("CARGO_BIN_EXE_tmc-langs-cli"); |
| 25 | + let mut child = Command::new(path) |
| 26 | + .stdout(Stdio::piped()) |
| 27 | + .stdin(Stdio::piped()) |
| 28 | + .args(&["core", "--email", &email]) |
| 29 | + .args(args) |
| 30 | + .spawn() |
| 31 | + .unwrap(); |
| 32 | + let child_stdin = child.stdin.as_mut().unwrap(); |
| 33 | + let password_write = format!("{}\n", password); |
| 34 | + child_stdin.write_all(password_write.as_bytes()).unwrap(); |
| 35 | + let out = child.wait_with_output().unwrap(); |
| 36 | + out |
| 37 | +} |
| 38 | + |
| 39 | +#[test] |
| 40 | +#[ignore] |
| 41 | +fn download_model_solution() { |
| 42 | + todo!() |
| 43 | +} |
| 44 | + |
| 45 | +#[test] |
| 46 | +#[ignore] |
| 47 | +fn download_or_update_exercises() { |
| 48 | + todo!() |
| 49 | +} |
| 50 | + |
| 51 | +#[test] |
| 52 | +#[ignore] |
| 53 | +fn get_course_details() { |
| 54 | + todo!() |
| 55 | +} |
| 56 | + |
| 57 | +#[test] |
| 58 | +#[ignore] |
| 59 | +fn get_exercise_updates() { |
| 60 | + todo!() |
| 61 | +} |
| 62 | + |
| 63 | +#[test] |
| 64 | +#[ignore] |
| 65 | +fn get_organizations() { |
| 66 | + init(); |
| 67 | + let out = run_core_cmd(&["get-organizations"]); |
| 68 | + assert!(out.status.success()); |
| 69 | + let out = String::from_utf8(out.stdout).unwrap(); |
| 70 | + let _orgs: Vec<Organization> = serde_json::from_str(&out).unwrap(); |
| 71 | +} |
| 72 | + |
| 73 | +#[test] |
| 74 | +#[ignore] |
| 75 | +fn get_unread_reviews() { |
| 76 | + todo!() |
| 77 | +} |
| 78 | + |
| 79 | +#[test] |
| 80 | +#[ignore] |
| 81 | +fn list_courses() { |
| 82 | + init(); |
| 83 | + let out = run_core_cmd(&["list-courses", "--organization", "hy"]); |
| 84 | + assert!(out.status.success()); |
| 85 | + let out = String::from_utf8(out.stdout).unwrap(); |
| 86 | + let _courses: Vec<Course> = serde_json::from_str(&out).unwrap(); |
| 87 | +} |
| 88 | + |
| 89 | +#[test] |
| 90 | +#[ignore] |
| 91 | +fn mark_review_as_read() { |
| 92 | + todo!() |
| 93 | +} |
| 94 | + |
| 95 | +#[test] |
| 96 | +#[ignore] |
| 97 | +fn paste_with_comment() { |
| 98 | + todo!() |
| 99 | +} |
| 100 | + |
| 101 | +#[test] |
| 102 | +#[ignore] |
| 103 | +fn request_code_review() { |
| 104 | + todo!() |
| 105 | +} |
| 106 | + |
| 107 | +#[test] |
| 108 | +#[ignore] |
| 109 | +fn run_checkstyle() { |
| 110 | + todo!() |
| 111 | +} |
| 112 | + |
| 113 | +#[test] |
| 114 | +#[ignore] |
| 115 | +fn run_tests() { |
| 116 | + todo!() |
| 117 | +} |
| 118 | + |
| 119 | +#[test] |
| 120 | +#[ignore] |
| 121 | +fn send_feedback() { |
| 122 | + todo!() |
| 123 | +} |
| 124 | + |
| 125 | +#[test] |
| 126 | +#[ignore] |
| 127 | +fn submit() { |
| 128 | + todo!() |
| 129 | +} |
0 commit comments