Skip to content

Commit 57a3da7

Browse files
committed
updated integration tests
1 parent 1c70fab commit 57a3da7

File tree

5 files changed

+132
-1
lines changed

5 files changed

+132
-1
lines changed

tmc-langs-cli/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env

tmc-langs-cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ serde = "1"
2222
[dev-dependencies]
2323
tempfile = "3"
2424
mockito = "0.25"
25+
dotenv = "0.15"
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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+
}
File renamed without changes.

tmc-langs-cli/tests/test.rs renamed to tmc-langs-cli/tests/non_core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::env;
22
use std::process::{Command, Output};
33
use tempfile::tempdir;
44

5-
fn run_cmd(args: &[&str]) -> Output {
5+
pub fn run_cmd(args: &[&str]) -> Output {
66
let path = env::current_exe().unwrap().parent().unwrap().to_path_buf();
77
let path = path.parent().unwrap().join("tmc-langs-cli");
88
Command::new(path).args(args).output().unwrap()

0 commit comments

Comments
 (0)