This commit introduces a number of new tests for the `pkg/mining` package, increasing the overall test coverage from 8.2% to 40.7%. The following changes were made: - Added tests for the `XMRigMiner` struct, including its methods for installation, starting, stopping, and getting stats. - Added tests for the `Service` layer, including the API endpoints for listing, starting, stopping, and getting stats for miners. - Added tests for the `Manager`, including starting and stopping multiple miners, collecting stats, and getting hashrate history. - Introduced a `ManagerInterface` to decouple the `Service` layer from the concrete `Manager` implementation, facilitating testing with mocks.
12 lines
377 B
Go
12 lines
377 B
Go
package mining
|
|
|
|
// ManagerInterface defines the interface for a miner manager.
|
|
type ManagerInterface interface {
|
|
StartMiner(minerType string, config *Config) (Miner, error)
|
|
StopMiner(name string) error
|
|
GetMiner(name string) (Miner, error)
|
|
ListMiners() []Miner
|
|
ListAvailableMiners() []AvailableMiner
|
|
GetMinerHashrateHistory(name string) ([]HashratePoint, error)
|
|
Stop()
|
|
}
|