diff --git a/Cargo.toml b/Cargo.toml index 43aef96..bb6fb85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ crate-type = ["cdylib"] [dependencies] anyhow = "1.0.99" -atlas-local = { git = "https://github.com/mongodb/atlas-local-lib.git", rev = "0cc744d3af8b39c5db674d6d8d227c1f453536b5" } +atlas-local = { git = "https://github.com/mongodb/atlas-local-lib.git", rev = "532d5f3c52788cb14f746e7b10edb3ce33dad89e" } bollard = "0.19.2" napi = { version = "^3.3.0", features = ["async", "anyhow"] } napi-derive = "^3.2.5" diff --git a/__test__/index.spec.ts b/__test__/index.spec.ts index 3f38dc7..8791c52 100644 --- a/__test__/index.spec.ts +++ b/__test__/index.spec.ts @@ -46,10 +46,7 @@ test('smoke test', async (t) => { let getDeployment = await client.getDeployment(createDeploymentOptions.name) t.is(getDeployment.name,createDeploymentOptions.name) - let getConnectionStringOptions = { - containerIdOrName: createDeploymentOptions.name, - } - let connString = await client.getConnectionString(getConnectionStringOptions) + let connString = await client.getConnectionString(createDeploymentOptions.name) t.assert(connString === `mongodb://127.0.0.1:${getDeployment.portBindings.port}/?directConnection=true`) // Count deployments after creation diff --git a/index.d.ts b/index.d.ts index 192fc78..a502144 100644 --- a/index.d.ts +++ b/index.d.ts @@ -6,7 +6,7 @@ export declare class Client { listDeployments(): Promise> deleteDeployment(deploymentName: string): Promise getDeployment(deploymentName: string): Promise - getConnectionString(options: GetConnectionStringOptions): Promise + getConnectionString(deploymentName: string): Promise getDeploymentId(clusterIdOrName: string): Promise } @@ -68,12 +68,6 @@ export interface Deployment { telemetryBaseUrl?: string } -export interface GetConnectionStringOptions { - containerIdOrName: string - dbUsername?: string - dbPassword?: string -} - export interface MongoDbPortBinding { type: BindingType ip: string diff --git a/src/lib.rs b/src/lib.rs index 83a681e..ca7d0d9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -71,14 +71,10 @@ impl Client { } #[napi] - pub async fn get_connection_string( - &self, - options: crate::models::get_connection_string::GetConnectionStringOptions, - ) -> Result { - let options: atlas_local::models::GetConnectionStringOptions = options.into(); + pub async fn get_connection_string(&self, deployment_name: String) -> Result { self .client - .get_connection_string(options) + .get_connection_string(deployment_name) .await .context("get connection string") } diff --git a/src/models/get_connection_string.rs b/src/models/get_connection_string.rs deleted file mode 100644 index 96b48a7..0000000 --- a/src/models/get_connection_string.rs +++ /dev/null @@ -1,49 +0,0 @@ -use napi_derive::napi; - -#[napi(object)] -pub struct GetConnectionStringOptions { - pub container_id_or_name: String, - pub db_username: Option, - pub db_password: Option, -} - -impl From for atlas_local::models::GetConnectionStringOptions { - fn from(source: GetConnectionStringOptions) -> Self { - Self { - container_id_or_name: source.container_id_or_name, - db_username: source.db_username, - db_password: source.db_password, - } - } -} - -// test -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_get_connection_string_options() { - let options = GetConnectionStringOptions { - container_id_or_name: "test_container".into(), - db_username: Some("test_user".into()), - db_password: Some("test_pass".into()), - }; - - let get_connection_string_options: atlas_local::models::GetConnectionStringOptions = - options.into(); - - assert_eq!( - get_connection_string_options.container_id_or_name, - "test_container" - ); - assert_eq!( - get_connection_string_options.db_username, - Some("test_user".into()) - ); - assert_eq!( - get_connection_string_options.db_password, - Some("test_pass".into()) - ); - } -} diff --git a/src/models/mod.rs b/src/models/mod.rs index 7a58349..917fa27 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -1,3 +1,2 @@ pub mod create_deployment; -pub mod get_connection_string; pub mod list_deployments;