generated from rmcguire/go-server-with-otel
implement econet exporter
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user