| 1 |
// Copyright 2025 The Jujutsu Authors |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// |
| 7 |
// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
// |
| 9 |
// Unless required by applicable law or agreed to in writing, software |
| 10 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
// See the License for the specific language governing permissions and |
| 13 |
// limitations under the License. |
| 14 |
|
| 15 |
use itertools::Itertools as _; |
| 16 |
|
| 17 |
use crate::common::default_config_from_schema; |
| 18 |
|
| 19 |
#[test] |
| 20 |
fn test_config_schema_default_values_are_consistent_with_schema() { |
| 21 |
let schema = serde_json::from_str(include_str!("../src/config-schema.json")) |
| 22 |
.expect("`config-schema.json` to be valid JSON"); |
| 23 |
let validator = |
| 24 |
jsonschema::validator_for(&schema).expect("`config-schema.json` to be a valid schema"); |
| 25 |
let schema_defaults = default_config_from_schema(); |
| 26 |
|
| 27 |
let evaluation = validator.evaluate(&schema_defaults); |
| 28 |
if !evaluation.flag().valid { |
| 29 |
panic!( |
| 30 |
"Failed to validate the schema defaults:\n{}", |
| 31 |
evaluation |
| 32 |
.iter_errors() |
| 33 |
.map(|err| format!("* {}: {}", err.instance_location, err.error)) |
| 34 |
.join("\n") |
| 35 |
); |
| 36 |
} |
| 37 |
} |