Skip to content

Commit 70dbc95

Browse files
committed
refactor: move KNOWN_KEYS to core/config.py and assert key not persisted in test
Signed-off-by: 🄂ʏᴇᴅ 🄰ʙᴅᴜʟ 🄰ᴍᴀ🄝 ✧ <amanbaba9404522@gmail.com>
1 parent 169d801 commit 70dbc95

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/pumpfun_cli/commands/config.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import typer
44

5-
from pumpfun_cli.core.config import delete_config_value, load_config, save_config_value
5+
from pumpfun_cli.core.config import KNOWN_KEYS, delete_config_value, load_config, save_config_value
66
from pumpfun_cli.group import JsonAwareGroup
77
from pumpfun_cli.output import error, render
88

@@ -18,8 +18,6 @@ def _config_callback(ctx: typer.Context):
1818
raise SystemExit(0)
1919

2020

21-
KNOWN_KEYS = {"rpc", "keyfile", "priority_fee", "compute_units"}
22-
2321

2422
@app.command("set")
2523
def config_set(ctx: typer.Context, key: str, value: str):

src/pumpfun_cli/core/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def delete_config_value(key: str):
5757
"compute_units": "PUMPFUN_COMPUTE_UNITS",
5858
}
5959

60+
KNOWN_KEYS: frozenset[str] = frozenset(ENV_MAP)
6061

6162
def resolve_value(key: str, flag: str | None = None) -> str | None:
6263
if flag is not None:

tests/test_commands/test_config_cmd.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,16 @@ def test_config_get_json_trailing(tmp_path, monkeypatch):
8383

8484

8585
def test_config_set_unknown_key(tmp_path, monkeypatch):
86-
"""config set rejects unknown config keys."""
86+
"""config set rejects unknown config keys and does not persist them."""
8787
monkeypatch.setenv("XDG_CONFIG_HOME", str(tmp_path))
8888
result = runner.invoke(app, ["config", "set", "rpcc", "https://example.com"])
8989
assert result.exit_code != 0
9090
assert "unknown config key" in result.output.lower()
9191
assert "valid keys" in result.output.lower()
92+
93+
# Assert the invalid key was not persisted
94+
list_result = runner.invoke(app, ["--json", "config", "list"])
95+
assert list_result.exit_code == 0
96+
import json
97+
data = json.loads(list_result.output) if list_result.output.strip() else {}
98+
assert "rpcc" not in data

0 commit comments

Comments
 (0)