Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
d8291150d4 | |||
4a35f11553 | |||
399c694c3e |
@ -21,7 +21,7 @@ version: 0.1.0
|
|||||||
# incremented each time you make changes to the application. Versions are not expected to
|
# incremented each time you make changes to the application. Versions are not expected to
|
||||||
# follow Semantic Versioning. They should reflect the version the application is using.
|
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||||
# It is recommended to use it with quotes.
|
# It is recommended to use it with quotes.
|
||||||
appVersion: "0.9.0"
|
appVersion: "v0.10.1"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- name: hull
|
- name: hull
|
||||||
|
@ -130,7 +130,7 @@ hull:
|
|||||||
main:
|
main:
|
||||||
image:
|
image:
|
||||||
repository: _HT*hull.config.settings.repo
|
repository: _HT*hull.config.settings.repo
|
||||||
tag: _HT!{{ printf "v%s" _HT*hull.config.settings.tag }}
|
tag: _HT*hull.config.settings.tag
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
args:
|
args:
|
||||||
- -config
|
- -config
|
||||||
|
113
pkg/weather/grpc/mapupdate_test.go
Normal file
113
pkg/weather/grpc/mapupdate_test.go
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
package grpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"k8s.io/utils/ptr"
|
||||||
|
|
||||||
|
pb "gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weather"
|
||||||
|
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/ambient/config"
|
||||||
|
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather"
|
||||||
|
)
|
||||||
|
|
||||||
|
var mockUpdate = &weather.WeatherUpdate{
|
||||||
|
DateUTC: &time.Time{},
|
||||||
|
StationConfig: &config.WeatherStation{
|
||||||
|
Name: "50W",
|
||||||
|
Equipment: "WS-5000",
|
||||||
|
},
|
||||||
|
StationID: ptr.To("50W"),
|
||||||
|
StationType: ptr.To("WS-5000"),
|
||||||
|
TempOutdoorF: ptr.To(97.6),
|
||||||
|
TempIndoorF: ptr.To(77.6),
|
||||||
|
HumidityOudoor: ptr.To(50),
|
||||||
|
HumidityIndoor: ptr.To(50),
|
||||||
|
WindSpeedMPH: ptr.To(20.5),
|
||||||
|
WindGustMPH: ptr.To(30.5),
|
||||||
|
MaxDailyGust: ptr.To(40.0),
|
||||||
|
WindDir: ptr.To(180),
|
||||||
|
WindDirAvg10m: ptr.To(180),
|
||||||
|
UV: nil,
|
||||||
|
SolarRadiation: ptr.To(9.999),
|
||||||
|
HourlyRainIn: ptr.To(9.999),
|
||||||
|
EventRainIn: ptr.To(9.999),
|
||||||
|
DailyRainIn: ptr.To(9.999),
|
||||||
|
WeeklyRainIn: ptr.To(9.999),
|
||||||
|
MonthlyRainIn: ptr.To(9.999),
|
||||||
|
YearlyRainIn: ptr.To(9.999),
|
||||||
|
TotalRainIn: ptr.To(9.999),
|
||||||
|
Batteries: []weather.BatteryStatus{
|
||||||
|
{Component: "battery1", Status: ptr.To(1)},
|
||||||
|
{Component: "battery2", Status: ptr.To(1)},
|
||||||
|
},
|
||||||
|
BaromRelativeIn: ptr.To(9.999),
|
||||||
|
BaromAbsoluteIn: ptr.To(9.999),
|
||||||
|
DewPointF: ptr.To(9.999),
|
||||||
|
WindChillF: ptr.To(9.999),
|
||||||
|
TempHumiditySensors: []*weather.TempHumiditySensor{
|
||||||
|
{Name: "sensor1", TempF: ptr.To(99.999), Humidity: nil},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUpdateToPbUpdate(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
u *weather.WeatherUpdate
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
want *pb.WeatherUpdate
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Map Update to PB",
|
||||||
|
args: args{u: mockUpdate},
|
||||||
|
want: &pb.WeatherUpdate{
|
||||||
|
StationName: mockUpdate.StationConfig.Name,
|
||||||
|
StationType: *mockUpdate.StationType,
|
||||||
|
StationId: *mockUpdate.StationID,
|
||||||
|
TempOutdoorF: mockUpdate.TempOutdoorF,
|
||||||
|
TempIndoorF: mockUpdate.TempIndoorF,
|
||||||
|
HumidityOutdoor: ptr.To(int32(*mockUpdate.HumidityOudoor)),
|
||||||
|
HumidityIndoor: ptr.To(int32(*mockUpdate.HumidityIndoor)),
|
||||||
|
WindSpeedMph: mockUpdate.WindSpeedMPH,
|
||||||
|
WindGustMph: mockUpdate.WindGustMPH,
|
||||||
|
MaxDailyGust: mockUpdate.MaxDailyGust,
|
||||||
|
WindDir: ptr.To(int32(*mockUpdate.WindDir)),
|
||||||
|
WindDirAvg_10M: ptr.To(int32(*mockUpdate.WindDirAvg10m)),
|
||||||
|
Uv: nil,
|
||||||
|
SolarRadiation: mockUpdate.SolarRadiation,
|
||||||
|
HourlyRainIn: mockUpdate.HourlyRainIn,
|
||||||
|
EventRainIn: mockUpdate.EventRainIn,
|
||||||
|
DailyRainIn: mockUpdate.DailyRainIn,
|
||||||
|
WeeklyRainIn: mockUpdate.WeeklyRainIn,
|
||||||
|
MonthlyRainIn: mockUpdate.MonthlyRainIn,
|
||||||
|
YearlyRainIn: mockUpdate.YearlyRainIn,
|
||||||
|
TotalRainIn: mockUpdate.TotalRainIn,
|
||||||
|
Batteries: []*pb.BatteryStatus{
|
||||||
|
{Component: mockUpdate.Batteries[0].Component, Status: ptr.To(int32(*mockUpdate.Batteries[0].Status))},
|
||||||
|
{Component: mockUpdate.Batteries[1].Component, Status: ptr.To(int32(*mockUpdate.Batteries[1].Status))},
|
||||||
|
},
|
||||||
|
BaromRelativeIn: mockUpdate.BaromRelativeIn,
|
||||||
|
BaromAbsoluteIn: mockUpdate.BaromAbsoluteIn,
|
||||||
|
DewPointF: mockUpdate.DewPointF,
|
||||||
|
WindChillF: mockUpdate.WindChillF,
|
||||||
|
TempHumiditySensors: []*pb.TempHumiditySensor{
|
||||||
|
{
|
||||||
|
Name: mockUpdate.TempHumiditySensors[0].Name,
|
||||||
|
TempF: mockUpdate.TempHumiditySensors[0].TempF,
|
||||||
|
Humidity: nil,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if got := UpdateToPbUpdate(tt.args.u); !reflect.DeepEqual(got, tt.want) {
|
||||||
|
t.Errorf("UpdateToPbUpdate() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user