From 302ea6e13926bfc99151ef029cb0697e41c91b79 Mon Sep 17 00:00:00 2001 From: Wei Zhang Date: Tue, 17 Dec 2024 20:10:24 +0800 Subject: [PATCH] chore: fix tests Signed-off-by: Wei Zhang --- crates/tabby-index/src/code/intelligence.rs | 6 ++++-- crates/tabby-index/src/indexer_tests.rs | 3 ++- crates/tabby/src/services/code.rs | 1 + ee/tabby-webserver/src/service/answer.rs | 6 ++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/tabby-index/src/code/intelligence.rs b/crates/tabby-index/src/code/intelligence.rs index d6d6ae70099f..3976d3c4e646 100644 --- a/crates/tabby-index/src/code/intelligence.rs +++ b/crates/tabby-index/src/code/intelligence.rs @@ -265,12 +265,14 @@ mod tests { fn test_create_source_file() { set_tabby_root(get_tabby_root()); let config = get_repository_config(); - let source_file = CodeIntelligence::compute_source_file(&config, &get_rust_source_file()) - .expect("Failed to create source file"); + let source_file = + CodeIntelligence::compute_source_file(&config, "commit", &get_rust_source_file()) + .expect("Failed to create source file"); // check source_file properties assert_eq!(source_file.language, "rust"); assert_eq!(source_file.tags.len(), 3); assert_eq!(source_file.filepath, "rust.rs"); + assert_eq!(source_file.commit, "commit"); } } diff --git a/crates/tabby-index/src/indexer_tests.rs b/crates/tabby-index/src/indexer_tests.rs index 365deb539aa1..cabeef445d1a 100644 --- a/crates/tabby-index/src/indexer_tests.rs +++ b/crates/tabby-index/src/indexer_tests.rs @@ -206,7 +206,8 @@ mod builder_tests { let builder = Arc::new(create_code_builder(Some(Arc::new(embedding)))); let repo = get_repository_config(); - let code = CodeIntelligence::compute_source_file(&repo, &get_rust_source_file()).unwrap(); + let code = CodeIntelligence::compute_source_file(&repo, "commit", &get_rust_source_file()) + .unwrap(); let index_id = code.to_index_id(); let (id, s) = tokio::runtime::Runtime::new() diff --git a/crates/tabby/src/services/code.rs b/crates/tabby/src/services/code.rs index a99b102ba833..03080ddb34b4 100644 --- a/crates/tabby/src/services/code.rs +++ b/crates/tabby/src/services/code.rs @@ -298,6 +298,7 @@ mod tests { body: body.to_string(), filepath: "".to_owned(), git_url: "".to_owned(), + commit: "".to_owned(), language: "".to_owned(), start_line: 0, }, diff --git a/ee/tabby-webserver/src/service/answer.rs b/ee/tabby-webserver/src/service/answer.rs index 9f4d9f9ebaba..d7a6d256968a 100644 --- a/ee/tabby-webserver/src/service/answer.rs +++ b/ee/tabby-webserver/src/service/answer.rs @@ -767,6 +767,7 @@ mod tests { })], code: vec![tabby_schema::thread::MessageAttachmentCode { git_url: "https://github.com/".to_owned(), + commit: "commit".to_owned(), filepath: "server.py".to_owned(), language: "python".to_owned(), content: "from flask import Flask\n\napp = Flask(__name__)\n\n@app.route('/')\ndef hello():\n return 'Hello, World!'".to_owned(), @@ -800,6 +801,7 @@ mod tests { )], code: vec![tabby_schema::thread::MessageAttachmentCode { git_url: "https://github.com".to_owned(), + commit: "commit".to_owned(), filepath: "server.py".to_owned(), language: "python".to_owned(), content: "print('Hello, server!')".to_owned(), @@ -976,6 +978,7 @@ mod tests { )], code: vec![tabby_schema::thread::MessageAttachmentCode { git_url: "https://github.com".to_owned(), + commit: "commit".to_owned(), filepath: "server.py".to_owned(), language: "python".to_owned(), content: "print('Hello, server!')".to_owned(), @@ -1037,6 +1040,7 @@ mod tests { )], code: vec![tabby_schema::thread::MessageAttachmentCode { git_url: "https://github.com".to_owned(), + commit: "commit".to_owned(), filepath: "server.py".to_owned(), language: "python".to_owned(), content: "print('Hello, server!')".to_owned(), @@ -1334,6 +1338,7 @@ mod tests { body: "fn test1() {}\nfn test2() {}".to_string(), filepath: "test.rs".to_string(), git_url: "https://github.com/test/repo.git".to_string(), + commit: "commit".to_string(), language: "rust".to_string(), start_line: 1, }, @@ -1350,6 +1355,7 @@ mod tests { body: "fn test3() {}\nfn test4() {}".to_string(), filepath: "test.rs".to_string(), git_url: "https://github.com/test/repo.git".to_string(), + commit: "commit".to_string(), language: "rust".to_string(), start_line: 3, },