Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into ericapywang/create-index
Browse files Browse the repository at this point in the history
  • Loading branch information
ericapywang committed Jun 7, 2024
2 parents 0bc7db9 + 5aa32ed commit 11530db
Show file tree
Hide file tree
Showing 9 changed files with 477 additions and 32 deletions.
111 changes: 111 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions pinecone_sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,15 @@ edition = "2021"
[dependencies]
openapi = { path = "../openapi" }
tokio = { version = "1", features = ["full"] }
<<<<<<< HEAD
mockito = "0.30"
regex = "1.10.4"
=======
regex = "1.10.4"
serde_json = "1.0.117"
snafu = "0.8.3"

[dev-dependencies]
mockito = "0.30"
serial_test = "3.1.1"
>>>>>>> origin/main
8 changes: 6 additions & 2 deletions pinecone_sdk/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
use std::collections::HashMap;

#[derive(Debug, Clone)]
pub struct Config {
pub api_key: String,
pub controller_url: String,
pub additional_headers: HashMap<String, String>,
pub source_tag: Option<String>,
}

impl Config {
pub fn new(api_key: String) -> Self {
pub fn new(api_key: String, source_tag: Option<String>) -> Self {
Config {
api_key,
controller_url: "https://api.pinecone.io".to_string(),
source_tag: None,
additional_headers: HashMap::new(),
source_tag,
}
}
}
15 changes: 7 additions & 8 deletions pinecone_sdk/src/control/list_indexes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ impl Pinecone {
#[cfg(test)]
mod tests {
use super::*;
use mockito::mock;
use tokio;
use crate::control::list_indexes::models::index_model::Metric;
use crate::config::Config;
use openapi::models::IndexList;
use openapi::apis::configuration::Configuration;
use crate::control::list_indexes::models::index_model::Metric;
use mockito::mock;
use openapi::apis::configuration::ApiKey;
use openapi::apis::configuration::Configuration;
use openapi::models::IndexList;
use openapi::models::IndexModel;


use tokio;

#[tokio::test]
async fn test_list_indexes() {
Expand Down Expand Up @@ -66,7 +64,8 @@ mod tests {

// Construct Pinecone instance with the mock server URL
let api_key = "test_api_key".to_string();
let pinecone = Pinecone::new(api_key, Some(mockito::server_url()));
let pinecone = Pinecone::new(Some(api_key), Some(mockito::server_url()), None, None)
.expect("Failed to create Pinecone instance");

// Call list_indexes and verify the result
let result = pinecone.list_indexes().await;
Expand Down
2 changes: 1 addition & 1 deletion pinecone_sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ pub mod config;
pub mod control;
pub mod pinecone;
pub mod utils;
pub mod models;
pub mod models;
Loading

0 comments on commit 11530db

Please sign in to comment.