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

fix(core): allow stage with empty path #269

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion cli/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl Session {
None => 0.0,
Some(ss) => ss.running_time_ms,
};
println!("{:.6}", server_time_ms / 1000.0);
println!("{:.3}", server_time_ms / 1000.0);
}
}
Ok(())
Expand Down
13 changes: 10 additions & 3 deletions core/src/stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ impl TryFrom<&str> for StageLocation {
.next()
.ok_or_else(|| Error::Parsing(format!("Invalid stage location: {}", s)))?
.trim_start_matches('@');
let path = parts
.next()
.ok_or_else(|| Error::Parsing(format!("Invalid stage location: {}", s)))?;
let path = parts.next().unwrap_or_default();
Ok(Self {
name: name.to_string(),
path: path.to_string(),
Expand Down Expand Up @@ -69,6 +67,15 @@ mod test {
Ok(())
}

#[test]
fn parse_stage_empty_path() -> Result<()> {
let location = "@stage_name";
let stage = StageLocation::try_from(location)?;
assert_eq!(stage.name, "stage_name");
assert_eq!(stage.path, "");
Ok(())
}

#[test]
fn parse_stage_fail() -> Result<()> {
let location = "stage_name/path/to/file";
Expand Down