Skip to content

Commit 1cbd31e

Browse files
authored
Merge pull request #52 from dev-five-git/add-description-coverage
Add coverage test
2 parents c98bebd + ba52627 commit 1cbd31e

1 file changed

Lines changed: 51 additions & 15 deletions

File tree

crates/vespertide-cli/src/commands/status.rs

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -285,18 +285,54 @@ mod tests {
285285
cmd_status().unwrap();
286286
}
287287

288-
#[test]
289-
#[serial]
290-
fn cmd_status_differs_prints_diff_hint() {
291-
let tmp = tempdir().unwrap();
292-
let _guard = CwdGuard::new(&tmp.path().to_path_buf());
293-
294-
let cfg = write_config();
295-
write_model("users");
296-
// add another model to differ from baseline
297-
write_model("posts");
298-
write_migration(&cfg); // baseline only has users
299-
300-
cmd_status().unwrap();
301-
}
302-
}
288+
#[test]
289+
#[serial]
290+
fn cmd_status_differs_prints_diff_hint() {
291+
let tmp = tempdir().unwrap();
292+
let _guard = CwdGuard::new(&tmp.path().to_path_buf());
293+
294+
let cfg = write_config();
295+
write_model("users");
296+
// add another model to differ from baseline
297+
write_model("posts");
298+
write_migration(&cfg); // baseline only has users
299+
300+
cmd_status().unwrap();
301+
}
302+
303+
#[test]
304+
#[serial]
305+
fn cmd_status_model_with_description() {
306+
let tmp = tempdir().unwrap();
307+
let _guard = CwdGuard::new(&tmp.path().to_path_buf());
308+
309+
let cfg = write_config();
310+
fs::create_dir_all(cfg.models_dir()).unwrap();
311+
fs::create_dir_all(cfg.migrations_dir()).unwrap();
312+
313+
// Create a model with a description to cover lines 102-105
314+
let table = TableDef {
315+
name: "users".to_string(),
316+
description: Some("User accounts table".to_string()),
317+
columns: vec![ColumnDef {
318+
name: "id".into(),
319+
r#type: ColumnType::Simple(SimpleColumnType::Integer),
320+
nullable: false,
321+
default: None,
322+
comment: None,
323+
primary_key: None,
324+
unique: None,
325+
index: None,
326+
foreign_key: None,
327+
}],
328+
constraints: vec![TableConstraint::PrimaryKey {
329+
auto_increment: false,
330+
columns: vec!["id".into()],
331+
}],
332+
};
333+
let path = cfg.models_dir().join("users.json");
334+
fs::write(path, serde_json::to_string_pretty(&table).unwrap()).unwrap();
335+
336+
cmd_status().unwrap();
337+
}
338+
}

0 commit comments

Comments
 (0)