Skip to content

Commit

Permalink
added some initial integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
randommm committed Mar 9, 2024
1 parent 023c21a commit 0c0bd89
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 1 deletion.
157 changes: 157 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ pretty_env_logger = "0.5"

[profile.dev.package."*"]
opt-level = 3

[dev-dependencies]
axum-test = "14"
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod llm;
mod routes;
pub mod routes;
use log::info;
use tokio::net::TcpListener;

Expand Down
1 change: 1 addition & 0 deletions src/llm/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ mod tests {
use super::*;

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[ignore]
async fn sequential_dialog() {
let sample_len = 10_usize;
let temperature = Some(0.8);
Expand Down
24 changes: 24 additions & 0 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use axum_test::{TestServer, TestServerConfig};
use rust_slackbot_llm::routes::create_routes;
use serde_json::Value;

async fn new_test_app() -> TestServer {
let app = create_routes().await.unwrap();
let config = TestServerConfig::builder()
.expect_success_by_default()
.mock_transport()
.build();

TestServer::new_with_config(app, config).unwrap()
}

#[tokio::test]
async fn test_index() {
let server = new_test_app().await;

let response = server.get("/v1").await;

assert_eq!(response.status_code(), 200);
let expected_response: Value = "Welcome to the Rust Slackbot LLM API!".into();
response.assert_json(&expected_response);
}

0 comments on commit 0c0bd89

Please sign in to comment.