server

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBotEvent added in v0.2.0

func AddBotEvent(deal *tcmock.Deal, message string)

AddBotEvent adds a bot event to a deal message: Human-readable event description

func ExtractDealID added in v0.2.0

func ExtractDealID(url string) (int, error)

ExtractDealID is a helper to extract deal ID from a deal show URL

func NewBot added in v0.2.0

func NewBot(id int, name string, accountID int, enabled bool) tcmock.Bot

NewBot creates a minimal Bot with required fields populated This is a helper to make it easier to create test bots

func NewDeal added in v0.2.0

func NewDeal(id int, botID int, pair string, status string) tcmock.Deal

NewDeal creates a minimal Deal with required fields populated This is a helper to make it easier to create test deals

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) Close

func (ts *TestServer) Close()

Close shuts down the mock server

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) Reset

func (ts *TestServer) Reset()

Reset clears all state

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL