Add configurable device aliases
This commit is contained in:
@@ -46,6 +46,10 @@ func (writer *fakeWriter) firstBatch() []model.Record {
|
||||
func TestServiceFlushesParsedRecords(t *testing.T) {
|
||||
fake := newFakeWriter()
|
||||
service := NewService(config.Config{
|
||||
DeviceAliases: map[string]string{
|
||||
"tasmota-896001": "Garage Plug",
|
||||
"Tasmota C88994": "Office Plug",
|
||||
},
|
||||
App: config.AppConfig{
|
||||
BatchSize: 2,
|
||||
BufferSize: 8,
|
||||
@@ -90,6 +94,9 @@ func TestServiceFlushesParsedRecords(t *testing.T) {
|
||||
if batch[0].Fields["online"] != true {
|
||||
t.Fatalf("unexpected lwt online field: %#v", batch[0].Fields["online"])
|
||||
}
|
||||
if batch[0].Fields["device_alias"] != "Garage Plug" {
|
||||
t.Fatalf("unexpected lwt device_alias field: %#v", batch[0].Fields["device_alias"])
|
||||
}
|
||||
|
||||
if batch[1].Measurement != "tasmota_sensor" {
|
||||
t.Fatalf("unexpected second measurement: %s", batch[1].Measurement)
|
||||
@@ -97,6 +104,9 @@ func TestServiceFlushesParsedRecords(t *testing.T) {
|
||||
if batch[1].Fields["energy_total"] != float64(41.385) {
|
||||
t.Fatalf("unexpected sensor energy_total field: %#v", batch[1].Fields["energy_total"])
|
||||
}
|
||||
if batch[1].Fields["device_alias"] != "Office Plug" {
|
||||
t.Fatalf("unexpected sensor device_alias field: %#v", batch[1].Fields["device_alias"])
|
||||
}
|
||||
|
||||
cancel()
|
||||
select {
|
||||
|
||||
Reference in New Issue
Block a user