Files
cleveragents-core/features/config_cli_uncovered_branches.feature

113 lines
6.1 KiB
Gherkin

Feature: Config CLI uncovered branches
Cover missed lines and branches in config.py:
_settings_defaults registry path, _validate_key empty,
_write_config_file existing-file path, _resolve_source env path,
config_set/get non-rich formats, config_list empty result,
config_set --project flag, config_get --verbose flag.
# -- _settings_defaults returns defaults from registry --
Scenario: config cli branch settings defaults returns registry defaults
When I config cli branch call _settings_defaults
Then the config cli branch defaults should contain registry default values
# -- _settings_defaults with a mocked registry entry having None default --
Scenario: config cli branch settings defaults returns None for None-default entry
Given a config cli branch mocked registry entry with None default
When I config cli branch call _settings_defaults
Then the config cli branch defaults should contain None for the mocked key
# -- _validate_key with empty key (L102-103) --
Scenario: config cli branch validate_key rejects empty key
When I config cli branch call _validate_key with an empty key
Then the config cli branch call should raise BadParameter
# -- _write_config_file when file already exists --
Scenario: config cli branch write_config_file merges into existing file
Given a config cli branch temp config directory
And a config cli branch existing config file with key "core.log.level" set to "DEBUG"
When I config cli branch write config with key "plan.concurrency" set to "4"
Then the config cli branch config file should contain both keys
# -- _resolve_source returns "env_var" when env var is set --
Scenario: config cli branch resolve_source returns env_var when env var is set
Given a config cli branch temp config directory
And the config cli branch env var "CLEVERAGENTS_LOG_LEVEL" is set to "WARNING"
When I config cli branch call _resolve_source for "core.log.level"
Then the config cli branch source should be "env_var"
# -- config_set with non-rich format --
Scenario: config cli branch config set with json format uses format_output
Given a config cli branch temp config directory
When I config cli branch run config set "core.log.level" "DEBUG" with format "json"
Then the config cli branch set result should be valid JSON
And the config cli branch set JSON should contain key "key"
And the config cli branch set JSON should contain key "value"
# -- config_set with --project flag --
Scenario: config cli branch config set with project flag writes project-scoped value
Given a config cli branch temp config directory
When I config cli branch run config set "core.automation-profile" "manual" with project "local/prod"
Then the config cli branch set result for project should succeed
And the config cli branch set result should contain scope "project:local/prod"
# -- config_get with --verbose flag --
Scenario: config cli branch config get with verbose shows resolution chain
Given a config cli branch temp config directory
When I config cli branch run config get "core.log.level" with verbose
Then the config cli branch get verbose result should succeed
And the config cli branch get verbose output should contain resolution chain
# -- config_get with non-rich format and Path value --
Scenario: config cli branch config get with json format serialises Path values
Given a config cli branch temp config directory
And config cli branch resolve returns a Path value for "core.log.dir"
When I config cli branch run config get "core.log.dir" with format "json"
Then the config cli branch get result should be valid JSON
And the config cli branch get JSON value should be a string not a Path
# -- config_set with bool value coercion --
Scenario: config cli branch config set coerces bool value
Given a config cli branch temp config directory
When I config cli branch run config set "core.log.file-enabled" "false" with format "json"
Then the config cli branch set result should be valid JSON
And the config cli branch set JSON value should be bool false
# -- config_set with int value coercion --
Scenario: config cli branch config set coerces int value
Given a config cli branch temp config directory
When I config cli branch run config set "plan.concurrency" "8" with format "json"
Then the config cli branch set result should be valid JSON
And the config cli branch set JSON value should be int 8
# -- config_set with float value coercion --
Scenario: config cli branch config set coerces float value
Given a config cli branch temp config directory
When I config cli branch run config set "plan.budget.warn-threshold" "0.5" with format "json"
Then the config cli branch set result should be valid JSON
And the config cli branch set JSON value should be float 0.5
# -- config_list with filter matching nothing --
Scenario: config cli branch config list prints message when no matches
Given a config cli branch temp config directory
When I config cli branch run config list with pattern "zzz_nonexistent_pattern_xyz"
Then the config cli branch list output should say no values match
# -- config_list with invalid regex --
Scenario: config cli branch config list with invalid regex fails
Given a config cli branch temp config directory
When I config cli branch run config list with pattern "[invalid"
Then the config cli branch list result should fail with regex error
# -- config_get with unknown key --
Scenario: config cli branch config get with unknown key fails
Given a config cli branch temp config directory
When I config cli branch run config get "totally.bogus.key" with format "json"
Then the config cli branch get result should fail with unknown key error
# -- secret masking in list --
Scenario: config cli branch config list masks secret values
Given a config cli branch temp config directory
When I config cli branch run config list with format "json"
Then the config cli branch list result should be valid JSON
And the config cli branch list JSON should mask api-key values