parse topic 2
All checks were successful
Unit Tests / Run Tests (push) Successful in 11s

This commit is contained in:
Travis Shears 2026-03-25 11:21:04 +01:00
parent fbcafef67c
commit cad01edab8
Signed by: travisshears
GPG key ID: CB9BF1910F3F7469
3 changed files with 38 additions and 3 deletions

View file

@ -6,7 +6,7 @@ pub fn main() -> Nil {
gleeunit.main()
}
pub fn file_read_test() {
pub fn sensor_name_and_unit_test() {
let reading =
sensors.sensor_name(sensors.Temperature)
<> " "
@ -28,3 +28,17 @@ pub fn parse_topic_1_test() {
sensors.SensorReading(sensor: sensors.Pressure, value: 944.67),
])
}
pub fn parse_topic_2_test() {
let json_string = "{\"pm1\":16.83,\"pm2_5\":10.68,\"pm10\":16.619719}"
let readings = sensors.parse_topic_2(json_string)
readings
|> should.equal([
sensors.SensorReading(sensor: sensors.ParticalMatterOne, value: 16.83),
sensors.SensorReading(
sensor: sensors.ParticalMatterTwoPointFive,
value: 10.68,
),
sensors.SensorReading(sensor: sensors.ParticalMatterTen, value: 16.619719),
])
}