Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed Dec 13, 2024
1 parent c604dee commit 3a90b3c
Showing 1 changed file with 133 additions and 0 deletions.
133 changes: 133 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,139 @@ mod tests {
"#);
}

#[test]
fn language_version() {
let yaml = indoc::indoc! { r"
repos:
- repo: local
hooks:
- id: hook-1
name: hook 1
entry: echo hello world
language: system
language_version: default
- id: hook-2
name: hook 2
entry: echo hello world
language: system
language_version: system
- id: hook-3
name: hook 3
entry: echo hello world
language: system
language_version: '3.8'
"};
let result = serde_yaml::from_str::<Config>(yaml);
insta::assert_debug_snapshot!(result, @r#"
Ok(
Config {
repos: [
Local(
LocalRepo {
hooks: [
ManifestHook {
id: "hook-1",
name: "hook 1",
entry: "echo hello world",
language: System,
options: HookOptions {
alias: None,
files: None,
exclude: None,
types: None,
types_or: None,
exclude_types: None,
additional_dependencies: None,
args: None,
always_run: None,
fail_fast: None,
pass_filenames: None,
description: None,
language_version: Some(
Default,
),
log_file: None,
require_serial: None,
stages: None,
verbose: None,
minimum_pre_commit_version: None,
},
},
ManifestHook {
id: "hook-2",
name: "hook 2",
entry: "echo hello world",
language: System,
options: HookOptions {
alias: None,
files: None,
exclude: None,
types: None,
types_or: None,
exclude_types: None,
additional_dependencies: None,
args: None,
always_run: None,
fail_fast: None,
pass_filenames: None,
description: None,
language_version: Some(
System,
),
log_file: None,
require_serial: None,
stages: None,
verbose: None,
minimum_pre_commit_version: None,
},
},
ManifestHook {
id: "hook-3",
name: "hook 3",
entry: "echo hello world",
language: System,
options: HookOptions {
alias: None,
files: None,
exclude: None,
types: None,
types_or: None,
exclude_types: None,
additional_dependencies: None,
args: None,
always_run: None,
fail_fast: None,
pass_filenames: None,
description: None,
language_version: Some(
Specific(
"3.8",
),
),
log_file: None,
require_serial: None,
stages: None,
verbose: None,
minimum_pre_commit_version: None,
},
},
],
},
),
],
default_install_hook_types: None,
default_language_version: None,
default_stages: None,
files: None,
exclude: None,
fail_fast: None,
minimum_pre_commit_version: None,
ci: None,
},
)
"#);
}

#[test]
fn test_read_config() -> Result<()> {
let config = read_config(Path::new("tests/files/uv-pre-commit-config.yaml"))?;
Expand Down

0 comments on commit 3a90b3c

Please sign in to comment.