Skip to content

test: add unit tests for environment variable bindings (e.g. FACT_INODES_MAX) #730

@coderabbitai

Description

@coderabbitai

Summary

Add unit tests that verify environment variable bindings correctly populate the corresponding configuration values.

Currently there are no tests covering env-var bindings for CLI arguments such as FACT_INODES_MAX, FACT_INODE_MAX (old name), and other env-vars mapped in FactCli. These were deferred because std::env::set_var is process-global and inherently racy when tests run in parallel under the same process.

Motivation

The rename of FACT_INODE_MAXFACT_INODES_MAX in #729 highlighted the lack of test coverage for env-var bindings. A regression here (wrong env-var name in the #[arg(env = ...)] attribute) would not be caught by existing tests.

Suggested approach

  • Serialize env-var tests using a shared Mutex (or the serial_test crate) so they don't interfere with parallel tests.
  • Alternatively, scope tests to run with RUST_TEST_THREADS=1 or via a dedicated test binary target.
  • At minimum, add coverage for FACT_INODES_MAX populating bpf.inodes_max, and consider covering other env-var bindings in FactCli.
  • Ensure each test cleans up the env var (e.g., via std::env::remove_var) to prevent cross-test pollution.

References

/cc @Molter73

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions