generated from rmcguire/go-server-with-otel
39 lines
870 B
Go
39 lines
870 B
Go
package econetmcp
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
pb "gitea.libretechconsulting.com/rmcguire/econet-exporter/api/econet/v1alpha1"
|
|
)
|
|
|
|
func TestSummarizeDevices(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
devices []*pb.Device
|
|
want string // substring that must appear
|
|
}{
|
|
{"empty", nil, "No EcoNet devices found."},
|
|
{
|
|
name: "single",
|
|
devices: []*pb.Device{{
|
|
FriendlyName: "Garage",
|
|
GenericType: "heatpumpWaterHeater",
|
|
SerialNumber: "ABC123",
|
|
Mode: "heat-pump",
|
|
Setpoint: 125,
|
|
}},
|
|
want: "Garage (heatpumpWaterHeater, serial ABC123): mode=heat-pump setpoint=125",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := summarizeDevices(tt.devices)
|
|
if !strings.Contains(got, tt.want) {
|
|
t.Errorf("summarizeDevices() = %q, want substring %q", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|