Files
nofx/pyproject.toml
WquGuru ae09647468 test(trader): add comprehensive unit tests and CI coverage reporting (#823)
* chore(config): add Python and uv support to project

- Add comprehensive Python .gitignore rules (pycache, venv, pytest, etc.)
- Add uv package manager specific ignores (.uv/, uv.lock)
- Initialize pyproject.toml for Python tooling

Co-authored-by: tinkle-community <tinklefund@gmail.com>

* chore(deps): add testing dependencies

- Add github.com/stretchr/testify v1.11.1 for test assertions
- Add github.com/agiledragon/gomonkey/v2 v2.13.0 for mocking
- Promote github.com/rs/zerolog to direct dependency

Co-authored-by: tinkle-community <tinklefund@gmail.com>

* ci(workflow): add PR test coverage reporting

Add GitHub Actions workflow to run unit tests and report coverage on PRs:
- Run Go tests with race detection and coverage profiling
- Calculate coverage statistics and generate detailed reports
- Post coverage results as PR comments with visual indicators
- Fix Go version to 1.23 (was incorrectly set to 1.25.0)

Coverage guidelines:
- Green (>=80%): excellent
- Yellow (>=60%): good
- Orange (>=40%): fair
- Red (<40%): needs improvement

This workflow is advisory only and does not block PR merging.

Co-authored-by: tinkle-community <tinklefund@gmail.com>

* test(trader): add comprehensive unit tests for trader modules

Add unit test suites for multiple trader implementations:
- aster_trader_test.go: AsterTrader functionality tests
- auto_trader_test.go: AutoTrader lifecycle and operations tests
- binance_futures_test.go: Binance futures trader tests
- hyperliquid_trader_test.go: Hyperliquid trader tests
- trader_test_suite.go: Common test suite utilities and helpers

Also fix minor formatting issue in auto_trader.go (trailing whitespace)

Co-authored-by: tinkle-community <tinklefund@gmail.com>

* test(trader): preserve existing calculatePnLPercentage unit tests

Merge existing calculatePnLPercentage tests with incoming comprehensive test suite:
- Preserve TestCalculatePnLPercentage with 9 test cases covering edge cases
- Preserve TestCalculatePnLPercentage_RealWorldScenarios with 3 trading scenarios
- Add math package import for floating-point precision comparison
- All tests validate PnL percentage calculation with different leverage scenarios

Co-authored-by: tinkle-community <tinklefund@gmail.com>

---------

Co-authored-by: tinkle-community <tinklefund@gmail.com>
2025-11-09 17:43:28 +08:00

150 B