feat: add new dependencies and integration tests for markdown and text formats
This commit is contained in:
49
Cargo.lock
generated
49
Cargo.lock
generated
@@ -190,6 +190,7 @@ dependencies = [
|
|||||||
"clap",
|
"clap",
|
||||||
"git2",
|
"git2",
|
||||||
"ignore",
|
"ignore",
|
||||||
|
"tempfile",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
@@ -243,6 +244,22 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "errno"
|
||||||
|
version = "0.3.13"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fastrand"
|
||||||
|
version = "2.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "form_urlencoded"
|
name = "form_urlencoded"
|
||||||
version = "1.2.2"
|
version = "1.2.2"
|
||||||
@@ -523,6 +540,12 @@ dependencies = [
|
|||||||
"vcpkg",
|
"vcpkg",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "linux-raw-sys"
|
||||||
|
version = "0.9.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "litemap"
|
name = "litemap"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
@@ -664,6 +687,19 @@ version = "0.8.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustix"
|
||||||
|
version = "1.0.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"errno",
|
||||||
|
"libc",
|
||||||
|
"linux-raw-sys",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustversion"
|
name = "rustversion"
|
||||||
version = "1.0.22"
|
version = "1.0.22"
|
||||||
@@ -754,6 +790,19 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tempfile"
|
||||||
|
version = "3.21.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "15b61f8f20e3a6f7e0649d825294eaf317edce30f82cf6026e7e4cb9222a7d1e"
|
||||||
|
dependencies = [
|
||||||
|
"fastrand",
|
||||||
|
"getrandom",
|
||||||
|
"once_cell",
|
||||||
|
"rustix",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thread_local"
|
name = "thread_local"
|
||||||
version = "1.1.9"
|
version = "1.1.9"
|
||||||
|
@@ -9,6 +9,7 @@ chrono = "0.4.41"
|
|||||||
clap = { version = "4.5.45", features = ["derive"] }
|
clap = { version = "4.5.45", features = ["derive"] }
|
||||||
git2 = "0.20.2"
|
git2 = "0.20.2"
|
||||||
ignore = "0.4.23"
|
ignore = "0.4.23"
|
||||||
|
tempfile = "3.21.0"
|
||||||
tracing = "0.1.41"
|
tracing = "0.1.41"
|
||||||
tracing-subscriber = "0.3.19"
|
tracing-subscriber = "0.3.19"
|
||||||
walkdir = "2.5.0"
|
walkdir = "2.5.0"
|
||||||
|
4
tests/fixtures/example.rs
vendored
Normal file
4
tests/fixtures/example.rs
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
// This is a sample Rust file for testing purposes.
|
||||||
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
1
tests/fixtures/example.txt
vendored
Normal file
1
tests/fixtures/example.txt
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Example text file content
|
79
tests/integration_tests.rs
Normal file
79
tests/integration_tests.rs
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
use codebase_to_prompt::{Config, Format, run};
|
||||||
|
use std::fs;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_run_with_markdown_format() {
|
||||||
|
let temp_dir = tempfile::tempdir().unwrap();
|
||||||
|
let output_file = temp_dir.path().join("output.md");
|
||||||
|
|
||||||
|
let config = Config {
|
||||||
|
directory: PathBuf::from("tests/fixtures"),
|
||||||
|
output: Some(output_file.clone()),
|
||||||
|
include: vec!["rs".to_string()],
|
||||||
|
exclude: vec![],
|
||||||
|
format: Format::Markdown,
|
||||||
|
append_date: false,
|
||||||
|
append_git_hash: false,
|
||||||
|
line_numbers: false,
|
||||||
|
ignore_hidden: true,
|
||||||
|
respect_gitignore: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
let result = run(config);
|
||||||
|
assert!(result.is_ok());
|
||||||
|
|
||||||
|
let output_content = fs::read_to_string(output_file).unwrap();
|
||||||
|
assert!(output_content.contains("### `example.rs`"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_run_with_text_format() {
|
||||||
|
let temp_dir = tempfile::tempdir().unwrap();
|
||||||
|
let output_file = temp_dir.path().join("output.txt");
|
||||||
|
|
||||||
|
let config = Config {
|
||||||
|
directory: PathBuf::from("tests/fixtures"),
|
||||||
|
output: Some(output_file.clone()),
|
||||||
|
include: vec!["txt".to_string()],
|
||||||
|
exclude: vec![],
|
||||||
|
format: Format::Text,
|
||||||
|
append_date: false,
|
||||||
|
append_git_hash: false,
|
||||||
|
line_numbers: true,
|
||||||
|
ignore_hidden: true,
|
||||||
|
respect_gitignore: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
let result = run(config);
|
||||||
|
assert!(result.is_ok());
|
||||||
|
|
||||||
|
let output_content = fs::read_to_string(output_file).unwrap();
|
||||||
|
assert!(output_content.contains("1 | Example text file content"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_run_with_git_hash_append() {
|
||||||
|
let temp_dir = tempfile::tempdir().unwrap();
|
||||||
|
let output_file = temp_dir.path().join("output.txt");
|
||||||
|
|
||||||
|
let config = Config {
|
||||||
|
directory: PathBuf::from("tests/fixtures"),
|
||||||
|
output: Some(output_file.clone()),
|
||||||
|
include: vec!["txt".to_string()],
|
||||||
|
exclude: vec![],
|
||||||
|
format: Format::Text,
|
||||||
|
append_date: false,
|
||||||
|
append_git_hash: true,
|
||||||
|
line_numbers: false,
|
||||||
|
ignore_hidden: true,
|
||||||
|
respect_gitignore: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
let result = run(config);
|
||||||
|
assert!(result.is_ok());
|
||||||
|
|
||||||
|
let output_file_name = output_file.file_name().unwrap().to_str().unwrap();
|
||||||
|
assert!(output_file_name.contains("output"));
|
||||||
|
assert!(output_file_name.len() > "output".len());
|
||||||
|
}
|
Reference in New Issue
Block a user