test: ensure startup message is correct

This commit is contained in:
Khaïs COLIN 2025-05-03 19:00:41 +02:00
parent 6910407ad2
commit 7fbaec8743
7 changed files with 200 additions and 7 deletions

View file

@ -1,8 +1,18 @@
pub fn startup_msg() {
#[cfg(test)]
use insta::assert_snapshot;
pub fn startup_msg() -> String {
let name = env!("CARGO_PKG_NAME");
let version = env!("CARGO_PKG_VERSION");
let authors = env!("CARGO_PKG_AUTHORS");
println!("{name} v{version} started.",);
println!("Copyright 2025 {authors}. All rights reserved.")
format!(
"{name} v{version} started.\n\
Copyright 2025 {authors}. All rights reserved."
)
}
#[test]
fn test_startup_msg() {
assert_snapshot!(startup_msg())
}

View file

@ -4,7 +4,7 @@ use osdb::command::Command;
use osdb::error_display::OSDBError as _;
fn main() {
startup_msg();
println!("{}", startup_msg());
while let Some(input) = read_input() {
match input.parse::<Command>() {
Ok(cmd) => {

View file

@ -0,0 +1,6 @@
---
source: src/branding.rs
expression: startup_msg()
---
osdb v0.1.0 started.
Copyright 2025 Khaïs COLIN. All rights reserved.