release_checker/tests/list_overview_test.rs

90 lines
2.5 KiB
Rust

use application::configuration::{ArgumentParser, VcsType};
use application::{migrate, Application};
use serial_test::serial;
use std::cell::Cell;
use test_context::test_context;
use test_utilities::console::FakeConsole;
use test_utilities::notification::FakeNotification;
use test_utilities::{
database::FunctionalTestContext, get_current, get_current_count, get_origin, get_origins_count,
insert_current, insert_origin,
};
//TODO: expand this test to do an actual test of the output printed to the console some way
#[test_context(FunctionalTestContext)]
#[test]
#[serial]
fn should_print_current(context: &FunctionalTestContext) {
let parser = ArgumentParser {};
let arguments = vec![String::from("release_checker"), String::from("list")];
insert_origin(
String::from("name1"),
String::from("owner_name"),
String::from("repo_name"),
String::from("github"),
&context.settings.database.get_connection(),
);
insert_current(
String::from("name1"),
"1".to_string(),
"github".to_string(),
"email@domain.tld".to_string(),
&context.settings.database.get_connection(),
);
insert_origin(
String::from("name2"),
String::from("owner_name"),
String::from("repo_name"),
String::from("github"),
&context.settings.database.get_connection(),
);
insert_current(
String::from("name2"),
"1".to_string(),
"github".to_string(),
"email@domain.tld".to_string(),
&context.settings.database.get_connection(),
);
insert_origin(
String::from("name3"),
String::from("owner_name"),
String::from("repo_name"),
String::from("github"),
&context.settings.database.get_connection(),
);
insert_current(
String::from("name3"),
"1".to_string(),
"github".to_string(),
"email@domain.tld".to_string(),
&context.settings.database.get_connection(),
);
let times_print_is_called = Cell::new(0);
let fake_notification = FakeNotification { callback: || {} };
let fake_console = FakeConsole {
callback: || {
let mut called = times_print_is_called.get();
called += 1;
times_print_is_called.set(called);
},
};
let application = Application::new(
&context.settings,
&fake_console,
&fake_notification,
parser,
arguments,
);
application.run();
assert_eq!(3, times_print_is_called.get());
}