server

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

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 BotUpdate

type BotUpdate struct {
	Enabled *bool
	Name    *string
}

BotUpdate represents fields that can be updated on a bot

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

func (ts *TestServer) Close()

Close shuts down the mock server

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

Jump to

Keyboard shortcuts

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