Change hddtemp to always put temperature in temperature field (#1905)

Added unit tests for the changes

Fixes #1904
This commit is contained in:
Jonas Falck
2016-12-13 20:40:55 +01:00
committed by Cameron Sparr
parent c4c13c4e90
commit 74d8aef0c0
6 changed files with 131 additions and 14 deletions

View File

@@ -8,7 +8,7 @@ import (
"strings"
)
type disk struct {
type Disk struct {
DeviceName string
Model string
Temperature int32
@@ -16,12 +16,19 @@ type disk struct {
Status string
}
func Fetch(address string) ([]disk, error) {
type hddtemp struct {
}
func New() *hddtemp {
return &hddtemp{}
}
func (h *hddtemp) Fetch(address string) ([]Disk, error) {
var (
err error
conn net.Conn
buffer bytes.Buffer
disks []disk
disks []Disk
)
if conn, err = net.Dial("tcp", address); err != nil {
@@ -48,7 +55,7 @@ func Fetch(address string) ([]disk, error) {
status = temperatureField
}
disks = append(disks, disk{
disks = append(disks, Disk{
DeviceName: device,
Model: fields[offset+2],
Temperature: int32(temperature),