add validation for sensor data and fix tests

This commit is contained in:
2025-10-09 23:11:37 +02:00
parent 9d86fd394c
commit b012db856c
3 changed files with 53 additions and 29 deletions
+18 -18
View File
@@ -208,8 +208,8 @@ func Test_SensorData_IsOutOfRangeAbove(t *testing.T) {
name: "value above threshold",
data: SensorData{
SensorID: "temp-001",
Value: 150.0,
Timestamp: time.Now(),
Value: ptr(150.0),
Timestamp: ptr(time.Now()),
},
sensor: Sensor{
SensorID: "temp-001",
@@ -221,8 +221,8 @@ func Test_SensorData_IsOutOfRangeAbove(t *testing.T) {
name: "value below threshold",
data: SensorData{
SensorID: "temp-001",
Value: 50.0,
Timestamp: time.Now(),
Value: ptr(50.0),
Timestamp: ptr(time.Now()),
},
sensor: Sensor{
SensorID: "temp-001",
@@ -234,8 +234,8 @@ func Test_SensorData_IsOutOfRangeAbove(t *testing.T) {
name: "value equal to threshold",
data: SensorData{
SensorID: "temp-001",
Value: 100.0,
Timestamp: time.Now(),
Value: ptr(100.0),
Timestamp: ptr(time.Now()),
},
sensor: Sensor{
SensorID: "temp-001",
@@ -247,8 +247,8 @@ func Test_SensorData_IsOutOfRangeAbove(t *testing.T) {
name: "negative value above negative threshold",
data: SensorData{
SensorID: "temp-001",
Value: -5.0,
Timestamp: time.Now(),
Value: ptr(-5.0),
Timestamp: ptr(time.Now()),
},
sensor: Sensor{
SensorID: "temp-001",
@@ -282,8 +282,8 @@ func Test_SensorData_IsOutOfRangeBelow(t *testing.T) {
name: "value below threshold",
data: SensorData{
SensorID: "temp-001",
Value: 5.0,
Timestamp: time.Now(),
Value: ptr(5.0),
Timestamp: ptr(time.Now()),
},
sensor: Sensor{
SensorID: "temp-001",
@@ -295,8 +295,8 @@ func Test_SensorData_IsOutOfRangeBelow(t *testing.T) {
name: "value above threshold",
data: SensorData{
SensorID: "temp-001",
Value: 50.0,
Timestamp: time.Now(),
Value: ptr(50.0),
Timestamp: ptr(time.Now()),
},
sensor: Sensor{
SensorID: "temp-001",
@@ -308,8 +308,8 @@ func Test_SensorData_IsOutOfRangeBelow(t *testing.T) {
name: "value equal to threshold",
data: SensorData{
SensorID: "temp-001",
Value: 10.0,
Timestamp: time.Now(),
Value: ptr(10.0),
Timestamp: ptr(time.Now()),
},
sensor: Sensor{
SensorID: "temp-001",
@@ -321,8 +321,8 @@ func Test_SensorData_IsOutOfRangeBelow(t *testing.T) {
name: "negative value below threshold",
data: SensorData{
SensorID: "temp-001",
Value: -15.0,
Timestamp: time.Now(),
Value: ptr(-15.0),
Timestamp: ptr(time.Now()),
},
sensor: Sensor{
SensorID: "temp-001",
@@ -334,8 +334,8 @@ func Test_SensorData_IsOutOfRangeBelow(t *testing.T) {
name: "zero value below positive threshold",
data: SensorData{
SensorID: "temp-001",
Value: 0.0,
Timestamp: time.Now(),
Value: ptr(0.0),
Timestamp: ptr(time.Now()),
},
sensor: Sensor{
SensorID: "temp-001",