v0.1.3-pre.010-fix.001
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
# file: Cargo.toml
|
# file: Cargo.toml
|
||||||
# version: 52
|
# version: 53
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "3"
|
resolver = "3"
|
||||||
members = ["crates/ksp-config-lib", "crates/ksp-core-lib", "crates/ksp-logging-lib"]
|
members = ["crates/ksp-config-lib", "crates/ksp-core-lib", "crates/ksp-logging-lib"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.1.3-pre.10"
|
version = "0.1.3-pre.10.fix.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://git.sasedev.com/Sasedev/khadhroony-solana-project"
|
repository = "https://git.sasedev.com/Sasedev/khadhroony-solana-project"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// file: crates/ksp-config-lib/unit_tests/environment.rs
|
// file: crates/ksp-config-lib/unit_tests/environment.rs
|
||||||
// version: 1
|
// version: 2
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn process_environment_wins_over_dotenv_and_fallback_even_when_empty() {
|
fn process_environment_wins_over_dotenv_and_fallback_even_when_empty() {
|
||||||
@@ -175,7 +175,8 @@ fn fake_process_collection_filters_unrelated_names_without_mutating_real_environ
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn committed_logging_profile_resolves_environment_fallback_without_changing_source_profile() {
|
fn committed_logging_profile_resolves_environment_fallback_without_changing_source_profile() {
|
||||||
let bootstrap = crate::ConfigBootstrapOptions::from_paths(std::path::PathBuf::from("config"), std::path::PathBuf::from("config/schemas"));
|
let workspace = workspace_root();
|
||||||
|
let bootstrap = crate::ConfigBootstrapOptions::from_paths(workspace.join("config"), workspace.join("config/schemas"));
|
||||||
assert!(bootstrap.is_ok(), "bootstrap should resolve committed roots");
|
assert!(bootstrap.is_ok(), "bootstrap should resolve committed roots");
|
||||||
let bootstrap = match bootstrap {
|
let bootstrap = match bootstrap {
|
||||||
std::result::Result::Ok(value) => value,
|
std::result::Result::Ok(value) => value,
|
||||||
@@ -212,7 +213,7 @@ fn committed_logging_profile_resolves_environment_fallback_without_changing_sour
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn env_example_inventory_contains_current_runtime_variable_with_preceding_comment() {
|
fn env_example_inventory_contains_current_runtime_variable_with_preceding_comment() {
|
||||||
let content = std::fs::read_to_string(".env.example");
|
let content = std::fs::read_to_string(workspace_root().join(crate::DEFAULT_DOTENV_EXAMPLE_PATH));
|
||||||
assert!(content.is_ok(), ".env.example must be committed at workspace root");
|
assert!(content.is_ok(), ".env.example must be committed at workspace root");
|
||||||
let content = match content {
|
let content = match content {
|
||||||
std::result::Result::Ok(value) => value,
|
std::result::Result::Ok(value) => value,
|
||||||
@@ -229,3 +230,7 @@ fn env_example_inventory_contains_current_runtime_variable_with_preceding_commen
|
|||||||
}
|
}
|
||||||
assert!(found, "current Config environment variable must appear in .env.example");
|
assert!(found, "current Config environment variable must appear in .env.example");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn workspace_root() -> std::path::PathBuf {
|
||||||
|
return std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../..");
|
||||||
|
}
|
||||||
|
|||||||
68
deltas/0.1.3/pre.010-fix.001.md
Normal file
68
deltas/0.1.3/pre.010-fix.001.md
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<!-- file: deltas/0.1.3/pre.010-fix.001.md -->
|
||||||
|
<!-- version: 1 -->
|
||||||
|
|
||||||
|
# Delta 0.1.3-pre.010-fix.001
|
||||||
|
|
||||||
|
## Objectif
|
||||||
|
|
||||||
|
Corriger deux tests unitaires de `pre.010` qui dépendaient à tort du répertoire courant du binaire de test pour retrouver les fichiers versionnés du workspace.
|
||||||
|
|
||||||
|
Le resolver environnemental, le parser `.env`, `.env.example`, les contrats publics et les dépendances restent inchangés.
|
||||||
|
|
||||||
|
## Cause
|
||||||
|
|
||||||
|
Les tests :
|
||||||
|
|
||||||
|
```text
|
||||||
|
committed_logging_profile_resolves_environment_fallback_without_changing_source_profile
|
||||||
|
env_example_inventory_contains_current_runtime_variable_with_preceding_comment
|
||||||
|
```
|
||||||
|
|
||||||
|
utilisaient respectivement :
|
||||||
|
|
||||||
|
```text
|
||||||
|
config/
|
||||||
|
config/schemas/
|
||||||
|
.env.example
|
||||||
|
```
|
||||||
|
|
||||||
|
comme chemins relatifs au current working directory du processus de test. Cette hypothèse n'est pas un contrat Cargo fiable et différait déjà des tests document/profile existants, qui dérivent la racine du workspace depuis `CARGO_MANIFEST_DIR`.
|
||||||
|
|
||||||
|
## Modifications
|
||||||
|
|
||||||
|
- `workspace.package.version` passe de `0.1.3-pre.10` à `0.1.3-pre.10.fix.1` ;
|
||||||
|
- le header du `Cargo.toml` racine passe de `52` à `53` ;
|
||||||
|
- `crates/ksp-config-lib/unit_tests/environment.rs` passe de la version de fichier `1` à `2` ;
|
||||||
|
- les deux tests concernés utilisent maintenant une fonction locale `workspace_root()` basée sur :
|
||||||
|
|
||||||
|
```text
|
||||||
|
env!("CARGO_MANIFEST_DIR")/../..
|
||||||
|
```
|
||||||
|
|
||||||
|
- le test du profil Logging ouvre donc les répertoires `config/` et `config/schemas/` sous la racine du workspace ;
|
||||||
|
- le test d'inventaire ouvre `.env.example` via `DEFAULT_DOTENV_EXAMPLE_PATH` sous cette même racine ;
|
||||||
|
- aucun fichier runtime Config, schema, `.env.example`, contrat public, resolver ou dépendance n'est modifié.
|
||||||
|
|
||||||
|
## Validation utilisateur de pre.010
|
||||||
|
|
||||||
|
Avant ce fix :
|
||||||
|
|
||||||
|
```text
|
||||||
|
cargo fmt --all OK
|
||||||
|
cargo check --workspace OK
|
||||||
|
cargo clippy --workspace --all-targets OK
|
||||||
|
cargo test --workspace 51/53 tests Config OK, 2 tests échoués
|
||||||
|
```
|
||||||
|
|
||||||
|
Les deux échecs sont ceux listés ci-dessus. Les autres tests, dont la priorité `process > .env > fallback`, le parser `.env`, les placeholders et les composites, passent.
|
||||||
|
|
||||||
|
## Validation attendue
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo fmt --all
|
||||||
|
cargo check --workspace
|
||||||
|
cargo clippy --workspace --all-targets
|
||||||
|
cargo test --workspace
|
||||||
|
```
|
||||||
|
|
||||||
|
Le résultat attendu est que les 53 tests unitaires de `ksp-config-lib` passent, ainsi que les 7 tests d'API publique et l'ensemble du workspace.
|
||||||
Reference in New Issue
Block a user