Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cli] skip checking connection string contains username and host #851

Merged
merged 1 commit into from
Jul 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions sea-orm-cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,8 @@ pub async fn run_generate_command(
// above
let url_username = url.username();
let url_host = url.host_str();

let is_sqlite = url.scheme() == "sqlite";

// Skip checking if it's SQLite
if !is_sqlite {
// Panic on any that are missing
if url_username.is_empty() {
panic!("No username was found in the database url");
}
if url_host.is_none() {
panic!("No host was found in the database url");
}
}

let tables = match tables {
Some(t) => t,
_ => "".to_string(),
Expand Down Expand Up @@ -445,25 +433,6 @@ mod tests {
}
}

#[test]
#[should_panic(expected = "No username was found in the database url")]
fn test_generate_entity_no_username() {
let cli = Cli::parse_from(vec![
"sea-orm-cli",
"generate",
"entity",
"--database-url",
"mysql://:root@localhost:3306/database",
]);

match cli.command {
Commands::Generate { command } => {
smol::block_on(run_generate_command(command, cli.verbose)).unwrap();
}
_ => unreachable!(),
}
}

#[test]
#[should_panic(expected = "called `Result::unwrap()` on an `Err` value: PoolTimedOut")]
fn test_generate_entity_no_password() {
Expand Down