Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Zhang <[email protected]>
  • Loading branch information
zwpaper committed Dec 17, 2024
1 parent 427e5c7 commit 302ea6e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
6 changes: 4 additions & 2 deletions crates/tabby-index/src/code/intelligence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
3 changes: 2 additions & 1 deletion crates/tabby-index/src/indexer_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions crates/tabby/src/services/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
6 changes: 6 additions & 0 deletions ee/tabby-webserver/src/service/answer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
},
Expand All @@ -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,
},
Expand Down

0 comments on commit 302ea6e

Please sign in to comment.