All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
37 lines
815 B
Go
37 lines
815 B
Go
package common
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"gitea.maximumdirect.net/ejr/feedkit/event"
|
|
)
|
|
|
|
func TestFinalizeRoundsWeatherPayloadFloats(t *testing.T) {
|
|
type payload struct {
|
|
Value float64
|
|
}
|
|
|
|
in := event.Event{
|
|
ID: "evt-1",
|
|
Kind: event.Kind("observation"),
|
|
Source: "source-a",
|
|
EmittedAt: time.Date(2026, 3, 28, 12, 0, 0, 0, time.UTC),
|
|
Schema: "raw.example.v1",
|
|
Payload: map[string]any{"old": true},
|
|
}
|
|
|
|
out, err := Finalize(in, "weather.example.v1", payload{Value: 1.234567}, time.Time{})
|
|
if err != nil {
|
|
t.Fatalf("Finalize() unexpected error: %v", err)
|
|
}
|
|
|
|
got, ok := out.Payload.(payload)
|
|
if !ok {
|
|
t.Fatalf("Finalize() payload type = %T, want payload", out.Payload)
|
|
}
|
|
if got.Value != 1.2346 {
|
|
t.Fatalf("Finalize() rounded value = %v, want 1.2346", got.Value)
|
|
}
|
|
}
|