Skip to content

Commit cc82093

Browse files
committed
Add cli test
1 parent 8dc8a0f commit cc82093

3 files changed

Lines changed: 178 additions & 0 deletions

File tree

Cargo.lock

Lines changed: 94 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/vespertide-cli/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ vespertide-exporter = { workspace = true }
2727
tempfile = "3"
2828
serial_test = "3"
2929
rstest = "0.26"
30+
assert_cmd = "2"
31+
predicates = "3"
3032

3133
[[bin]]
3234
name = "vespertide"
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
use assert_cmd::Command;
2+
use assert_cmd::cargo;
3+
use predicates::prelude::*;
4+
5+
fn vespertide() -> Command {
6+
Command::new(cargo::cargo_bin!("vespertide"))
7+
}
8+
9+
#[test]
10+
fn test_main_with_no_args_shows_help() {
11+
vespertide()
12+
.assert()
13+
.success()
14+
.stdout(predicate::str::contains("vespertide"));
15+
}
16+
17+
#[test]
18+
fn test_main_with_help_flag() {
19+
vespertide()
20+
.arg("--help")
21+
.assert()
22+
.success()
23+
.stdout(predicate::str::contains("vespertide"));
24+
}
25+
26+
#[test]
27+
fn test_main_with_diff_command() {
28+
// This will fail if not in a vespertide project, but tests the code path
29+
let mut cmd = vespertide();
30+
cmd.arg("diff");
31+
// Don't assert success since it may fail outside a project
32+
let _ = cmd.assert();
33+
}
34+
35+
#[test]
36+
fn test_main_with_sql_command() {
37+
let mut cmd = vespertide();
38+
cmd.arg("sql");
39+
let _ = cmd.assert();
40+
}
41+
42+
#[test]
43+
fn test_main_with_log_command() {
44+
let mut cmd = vespertide();
45+
cmd.arg("log");
46+
let _ = cmd.assert();
47+
}
48+
49+
#[test]
50+
fn test_main_with_status_command() {
51+
let mut cmd = vespertide();
52+
cmd.arg("status");
53+
let _ = cmd.assert();
54+
}
55+
56+
#[test]
57+
fn test_main_with_init_command() {
58+
let mut cmd = vespertide();
59+
cmd.arg("init");
60+
let _ = cmd.assert();
61+
}
62+
63+
#[test]
64+
fn test_main_with_new_command() {
65+
let mut cmd = vespertide();
66+
cmd.args(&["new", "test_table"]);
67+
let _ = cmd.assert();
68+
}
69+
70+
#[test]
71+
fn test_main_with_revision_command() {
72+
let mut cmd = vespertide();
73+
cmd.args(&["revision", "-m", "test message"]);
74+
let _ = cmd.assert();
75+
}
76+
77+
#[test]
78+
fn test_main_with_export_command() {
79+
let mut cmd = vespertide();
80+
cmd.args(&["export", "--orm", "seaorm"]);
81+
let _ = cmd.assert();
82+
}

0 commit comments

Comments
 (0)