Documentation
¶
Index ¶
- type Bot
- type BotEvent
- type BotUpdate
- type Deal
- type DealUpdate
- type TestServer
- func (ts *TestServer) AddBot(bot Bot)
- func (ts *TestServer) AddBotEvent(dealID int, event BotEvent) error
- func (ts *TestServer) AddDeal(botID int, deal Deal) error
- func (ts *TestServer) ClearErrors()
- func (ts *TestServer) Close()
- func (ts *TestServer) GetAllBots() []Bot
- func (ts *TestServer) GetAllDeals() []Deal
- func (ts *TestServer) GetBot(botID int) (Bot, bool)
- func (ts *TestServer) GetBotDeals(botID int) []Deal
- func (ts *TestServer) GetDeal(w http.ResponseWriter, r *http.Request, dealID tcmock.DealPathId)
- func (ts *TestServer) GetDealByID(dealID int) (Deal, bool)
- func (ts *TestServer) ListBots(w http.ResponseWriter, r *http.Request, params tcmock.ListBotsParams)
- func (ts *TestServer) ListDeals(w http.ResponseWriter, r *http.Request, params tcmock.ListDealsParams)
- func (ts *TestServer) RemoveBot(botID int)
- func (ts *TestServer) RemoveDeal(dealID int)
- func (ts *TestServer) Reset()
- func (ts *TestServer) SetBotError(botID int, err error)
- func (ts *TestServer) SetDealError(dealID int, err error)
- func (ts *TestServer) SetRateLimitError(enabled bool, retryAfter int)
- func (ts *TestServer) URL() string
- func (ts *TestServer) UpdateBot(botID int, updates BotUpdate) error
- func (ts *TestServer) UpdateDeal(dealID int, updates DealUpdate) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct {
ID int `json:"id"`
Name string `json:"name"`
Enabled bool `json:"is_enabled"`
AccountID int `json:"account_id"`
}
Bot represents a simplified bot for testing
type BotEvent ¶
type BotEvent struct {
CreatedAt string `json:"created_at"`
Action string `json:"action"` // "place", "cancel", "cancelled", "modify"
Coin string `json:"coin"` // "BTC", "ETH", etc.
Type string `json:"type"` // "buy", "sell"
Status string `json:"status"` // "active", "filled", "cancelled"
Price string `json:"price"` // Decimal string
Size string `json:"size"` // Decimal string
OrderType string `json:"order_type"` // "base", "safety", "take_profit"
OrderSize int `json:"order_size"` // Order size category
OrderPosition int `json:"order_position"` // Safety order position
IsMarket bool `json:"is_market"` // Whether order is market order
}
BotEvent represents a bot event with full structured data for testing This overrides the simple generated type to provide rich event details
type Deal ¶
type Deal struct {
ID int `json:"id"`
BotID int `json:"bot_id"`
Pair string `json:"pair"`
Status string `json:"status"`
ToCurrency string `json:"to_currency"`
FromCurrency string `json:"from_currency"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
Events []BotEvent `json:"bot_events"`
}
Deal represents a simplified deal for testing
type DealUpdate ¶
type DealUpdate struct {
Status *string
}
DealUpdate represents fields that can be updated on a deal
type TestServer ¶
type TestServer struct {
// contains filtered or unexported fields
}
TestServer wraps the mock 3Commas server for testing
func NewTestServer ¶
func NewTestServer(t *testing.T) *TestServer
NewTestServer creates a new mock 3Commas server for testing
func (*TestServer) AddBot ¶
func (ts *TestServer) AddBot(bot Bot)
AddBot adds a bot to the mock server's state
func (*TestServer) AddBotEvent ¶
func (ts *TestServer) AddBotEvent(dealID int, event BotEvent) error
AddBotEvent adds a new bot event to an existing deal
func (*TestServer) AddDeal ¶
func (ts *TestServer) AddDeal(botID int, deal Deal) error
AddDeal adds a deal to the mock server's state
func (*TestServer) ClearErrors ¶
func (ts *TestServer) ClearErrors()
ClearErrors removes all configured errors
func (*TestServer) GetAllBots ¶
func (ts *TestServer) GetAllBots() []Bot
GetAllBots returns all bots in the mock
func (*TestServer) GetAllDeals ¶
func (ts *TestServer) GetAllDeals() []Deal
GetAllDeals returns all deals in the mock
func (*TestServer) GetBot ¶
func (ts *TestServer) GetBot(botID int) (Bot, bool)
GetBot retrieves a bot by ID
func (*TestServer) GetBotDeals ¶
func (ts *TestServer) GetBotDeals(botID int) []Deal
GetBotDeals returns deals for a specific bot
func (*TestServer) GetDeal ¶
func (ts *TestServer) GetDeal(w http.ResponseWriter, r *http.Request, dealID tcmock.DealPathId)
GetDeal implements the ServerInterface method for GET /ver1/deals/{deal_id}/show
func (*TestServer) GetDealByID ¶
func (ts *TestServer) GetDealByID(dealID int) (Deal, bool)
GetDealByID retrieves a deal by ID (state management method)
func (*TestServer) ListBots ¶
func (ts *TestServer) ListBots(w http.ResponseWriter, r *http.Request, params tcmock.ListBotsParams)
ListBots implements the ServerInterface method for GET /ver1/bots
func (*TestServer) ListDeals ¶
func (ts *TestServer) ListDeals(w http.ResponseWriter, r *http.Request, params tcmock.ListDealsParams)
ListDeals implements the ServerInterface method for GET /ver1/deals
func (*TestServer) RemoveBot ¶
func (ts *TestServer) RemoveBot(botID int)
RemoveBot removes a bot from the mock
func (*TestServer) RemoveDeal ¶
func (ts *TestServer) RemoveDeal(dealID int)
RemoveDeal removes a deal from the mock
func (*TestServer) SetBotError ¶
func (ts *TestServer) SetBotError(botID int, err error)
SetBotError configures errors for specific bot operations
func (*TestServer) SetDealError ¶
func (ts *TestServer) SetDealError(dealID int, err error)
SetDealError configures errors for specific deal operations
func (*TestServer) SetRateLimitError ¶
func (ts *TestServer) SetRateLimitError(enabled bool, retryAfter int)
SetRateLimitError configures the mock to return rate limit errors
func (*TestServer) URL ¶
func (ts *TestServer) URL() string
URL returns the base URL of the mock server
func (*TestServer) UpdateBot ¶
func (ts *TestServer) UpdateBot(botID int, updates BotUpdate) error
UpdateBot updates a bot's state
func (*TestServer) UpdateDeal ¶
func (ts *TestServer) UpdateDeal(dealID int, updates DealUpdate) error
UpdateDeal updates a deal's state