Documentation
¶
Index ¶
- func AddBotEvent(deal *tcmock.Deal, message string)
- func ExtractDealID(url string) (int, error)
- func NewBot(id int, name string, accountID int, enabled bool) tcmock.Bot
- func NewDeal(id int, botID int, pair string, status string) tcmock.Deal
- type TestServer
- func (ts *TestServer) AddBot(bot tcmock.Bot)
- func (ts *TestServer) AddBotEventToDeal(dealID int, message string) error
- func (ts *TestServer) AddDeal(deal tcmock.Deal) error
- func (ts *TestServer) AllowDuplicateIDs(allow bool)
- func (ts *TestServer) ClearErrors()
- func (ts *TestServer) Close()
- func (ts *TestServer) GetAllBots() []tcmock.Bot
- func (ts *TestServer) GetAllDeals() []tcmock.Deal
- func (ts *TestServer) GetBot(botID int) (tcmock.Bot, bool)
- func (ts *TestServer) GetBotDeals(botID int) []tcmock.Deal
- func (ts *TestServer) GetDeal(w http.ResponseWriter, r *http.Request, dealID tcmock.DealPathId)
- func (ts *TestServer) GetDealByID(dealID int) (tcmock.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) LoadVCRCassette(cassettePath string) error
- func (ts *TestServer) LoadVCRCassettes(cassettePaths ...string) error
- 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) UpdateBotEnabled(botID int, enabled bool) error
- func (ts *TestServer) UpdateBotName(botID int, name string) error
- func (ts *TestServer) UpdateDealStatus(dealID int, status string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddBotEvent ¶ added in v0.2.0
AddBotEvent adds a bot event to a deal message: Human-readable event description
func ExtractDealID ¶ added in v0.2.0
ExtractDealID is a helper to extract deal ID from a deal show URL
Types ¶
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 tcmock.Bot)
AddBot adds a bot to the mock server's state
func (*TestServer) AddBotEventToDeal ¶ added in v0.2.0
func (ts *TestServer) AddBotEventToDeal(dealID int, message string) error
AddBotEventToDeal adds a new bot event to an existing deal message: Human-readable event description
func (*TestServer) AddDeal ¶
func (ts *TestServer) AddDeal(deal tcmock.Deal) error
AddDeal adds a deal to the mock server's state
func (*TestServer) AllowDuplicateIDs ¶ added in v0.2.1
func (ts *TestServer) AllowDuplicateIDs(allow bool)
AllowDuplicateIDs enables or disables duplicate ID checking When enabled, loading VCR cassettes with duplicate IDs will not return an error Instead, duplicate entries will be skipped (existing entries are preserved)
func (*TestServer) ClearErrors ¶
func (ts *TestServer) ClearErrors()
ClearErrors removes all configured errors
func (*TestServer) GetAllBots ¶
func (ts *TestServer) GetAllBots() []tcmock.Bot
GetAllBots returns all bots in the mock
func (*TestServer) GetAllDeals ¶
func (ts *TestServer) GetAllDeals() []tcmock.Deal
GetAllDeals returns all deals in the mock
func (*TestServer) GetBot ¶
func (ts *TestServer) GetBot(botID int) (tcmock.Bot, bool)
GetBot retrieves a bot by ID
func (*TestServer) GetBotDeals ¶
func (ts *TestServer) GetBotDeals(botID int) []tcmock.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) (tcmock.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) LoadVCRCassette ¶ added in v0.2.0
func (ts *TestServer) LoadVCRCassette(cassettePath string) error
LoadVCRCassette loads a VCR cassette and populates mock server state - Bots and Deals are loaded with ALL their data from real API responses - bot_events are PRESERVED exactly as recorded (this is the valuable part!) - Duplicate IDs will return an error unless AllowDuplicateIDs(true) is set - Non-2xx responses are skipped
func (*TestServer) LoadVCRCassettes ¶ added in v0.2.0
func (ts *TestServer) LoadVCRCassettes(cassettePaths ...string) error
LoadVCRCassettes loads multiple VCR cassettes in sequence
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) UpdateBotEnabled ¶ added in v0.2.0
func (ts *TestServer) UpdateBotEnabled(botID int, enabled bool) error
UpdateBotEnabled updates a bot's enabled state
func (*TestServer) UpdateBotName ¶ added in v0.2.0
func (ts *TestServer) UpdateBotName(botID int, name string) error
UpdateBotName updates a bot's name
func (*TestServer) UpdateDealStatus ¶ added in v0.2.0
func (ts *TestServer) UpdateDealStatus(dealID int, status string) error
UpdateDealStatus updates a deal's status