Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/pumpfun_cli/commands/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ def launch(
):
"""Launch a new token on pump.fun (create_v2 + extend_account)."""
state = ctx.obj
if not name or not name.strip():
error("Token name cannot be empty.")
if not ticker or not ticker.strip():
error("Token ticker cannot be empty.")
if not desc or not desc.strip():
error("Token description cannot be empty.")
if not state or not state.rpc:
error("RPC endpoint not configured.", hint="Run: pumpfun config set rpc <url>")

Expand Down
28 changes: 28 additions & 0 deletions tests/test_commands/test_launch_cmd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from unittest.mock import Mock

import pytest
from typer.testing import CliRunner

from pumpfun_cli.cli import app

runner = CliRunner()


@pytest.mark.parametrize(("name", "ticker", "desc", "expected_error"), [
("", "TST", "test", "token name cannot be empty."),
(" ", "TST", "test", "token name cannot be empty."),
("MyToken", "", "test", "token ticker cannot be empty."),
("MyToken", " ", "test", "token ticker cannot be empty."),
("MyToken", "TST", "", "token description cannot be empty."),
("MyToken", "TST", " ", "token description cannot be empty."),
])
def test_launch_rejects_empty_inputs(tmp_path, monkeypatch, name, ticker, desc, expected_error):
"""launch rejects empty or whitespace-only name, ticker, or description."""
monkeypatch.setenv("XDG_CONFIG_HOME", str(tmp_path))
launch_token_mock = Mock(side_effect=AssertionError("launch_token must not be called for invalid input"))
monkeypatch.setattr("pumpfun_cli.commands.launch.launch_token", launch_token_mock)

result = runner.invoke(app, ["launch", "--name", name, "--ticker", ticker, "--desc", desc])
assert result.exit_code != 0
assert expected_error in result.output.lower()
launch_token_mock.assert_not_called()
Loading