All checks were successful
Build and Publish / release (push) Successful in 4m6s
68 lines
1.7 KiB
Go
68 lines
1.7 KiB
Go
package config
|
|
|
|
import "testing"
|
|
|
|
func TestWeatherStation_MapSensor(t *testing.T) {
|
|
type fields struct {
|
|
Name string
|
|
Equipment string
|
|
WundergroundID string
|
|
WundergroundPassword string
|
|
AWNPassKey string
|
|
ProxyToAWN bool
|
|
ProxyToWunderground bool
|
|
KeepMetrics []string
|
|
DropMetrics []string
|
|
SensorMappings map[string]string
|
|
}
|
|
type args struct {
|
|
sensor string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
want string
|
|
}{
|
|
{
|
|
name: "Check sensor mapping",
|
|
fields: fields{
|
|
SensorMappings: map[string]string{
|
|
"TempHumiditySensor1": "TestSensor",
|
|
},
|
|
},
|
|
args: args{sensor: "TempHumiditySensor1"},
|
|
want: "TestSensor",
|
|
},
|
|
{
|
|
name: "Check sensor no mapping",
|
|
fields: fields{
|
|
SensorMappings: map[string]string{
|
|
"TempHumiditySensor1": "TestSensor",
|
|
},
|
|
},
|
|
args: args{sensor: "TempHumiditySensor2"},
|
|
want: "TempHumiditySensor2",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
ws := &WeatherStation{
|
|
Name: tt.fields.Name,
|
|
Equipment: tt.fields.Equipment,
|
|
WundergroundID: tt.fields.WundergroundID,
|
|
WundergroundPassword: tt.fields.WundergroundPassword,
|
|
AWNPassKey: tt.fields.AWNPassKey,
|
|
ProxyToAWN: tt.fields.ProxyToAWN,
|
|
ProxyToWunderground: tt.fields.ProxyToWunderground,
|
|
KeepMetrics: tt.fields.KeepMetrics,
|
|
DropMetrics: tt.fields.DropMetrics,
|
|
SensorMappings: tt.fields.SensorMappings,
|
|
}
|
|
if got := ws.MapSensor(tt.args.sensor); got != tt.want {
|
|
t.Errorf("WeatherStation.MapSensor() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|