Skip to content
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
10 changes: 5 additions & 5 deletions crates/vfs_cli_app/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1104,24 +1104,25 @@ mod tests {
"database",
"cycles",
"db_alpha",
"1.25",
"--browser-origin",
"http://127.0.0.1:3000",
]);
let Command::Database {
command:
DatabaseCommand::Cycles {
database_id,
kinic,
browser_origin,
},
} = cli.command
else {
panic!("expected database cycles command");
};
assert_eq!(database_id, "db_alpha");
assert_eq!(kinic, "1.25");
assert_eq!(browser_origin.as_deref(), Some("http://127.0.0.1:3000"));
assert!(
Cli::try_parse_from(["kinic-vfs-cli", "database", "cycles", "db_alpha", "1.25"])
.is_err()
);

let cli = Cli::parse_from(["kinic-vfs-cli", "database", "cycles-history", "db_alpha"]);
let Command::Database {
Expand Down Expand Up @@ -1278,8 +1279,7 @@ mod tests {
Cli::parse_from(["kinic-vfs-cli", "database", "cycles-history", "db_alpha"]);
assert!(database_cycles_history.command.requires_identity());

let database_cycles =
Cli::parse_from(["kinic-vfs-cli", "database", "cycles", "db_alpha", "1.25"]);
let database_cycles = Cli::parse_from(["kinic-vfs-cli", "database", "cycles", "db_alpha"]);
assert!(!database_cycles.command.requires_identity());
}

Expand Down
4 changes: 4 additions & 0 deletions crates/vfs_cli_app/src/commands_fs_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ impl VfsApi for MockClient {
})
}

async fn check_database_write_cycles(&self, _database_id: &str) -> Result<()> {
Ok(())
}

async fn list_databases(&self) -> Result<Vec<DatabaseSummary>> {
Ok(vec![DatabaseSummary {
database_id: "default".to_string(),
Expand Down
35 changes: 34 additions & 1 deletion crates/vfs_cli_app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Why: Wiki operations and Skill Registry operations share connection, identity, and DB selection.
use anyhow::Result;
use clap::Parser;
use vfs_cli::commands::{print_database_current, run_database_unlink};
use vfs_cli::commands::{open_database_cycles_page, print_database_current, run_database_unlink};
use vfs_cli::connection::{
ResolvedConnection, resolve_connection, resolve_connection_optional_canister,
};
Expand Down Expand Up @@ -37,6 +37,13 @@ async fn main() -> Result<()> {
run_database_unlink()?;
return Ok(());
}
DatabaseCommand::Cycles {
database_id,
browser_origin,
} => {
open_database_cycles_page(browser_origin.as_deref(), database_id)?;
return Ok(());
}
_ => {}
}
}
Expand Down Expand Up @@ -146,3 +153,29 @@ async fn new_identity_client(
)
.await
}

#[cfg(test)]
mod tests {
use super::*;
use vfs_cli::commands::database_cycles_url;

#[test]
fn database_cycles_url_resolves_without_connection_or_client() {
let command = DatabaseCommand::Cycles {
database_id: "db_alpha".to_string(),
browser_origin: Some("http://127.0.0.1:3000".to_string()),
};
let DatabaseCommand::Cycles {
database_id,
browser_origin,
} = command
else {
panic!("expected cycles command");
};

let url = database_cycles_url(browser_origin.as_deref(), &database_id)
.expect("cycles URL should build without canister client");

assert_eq!(url, "http://127.0.0.1:3000/cycles?database_id=db_alpha");
}
}
1 change: 0 additions & 1 deletion crates/vfs_cli_core/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ pub enum DatabaseCommand {
#[command(about = "Open the browser cycles purchase page for one database")]
Cycles {
database_id: String,
kinic: String,
#[arg(long)]
browser_origin: Option<String>,
},
Expand Down
Loading