Files
weatherreporter/internal/briefing/prepared_identity_test.go

27 lines
950 B
Go
Raw Permalink Normal View History

2026-08-13 01:52:11 +00:00
package briefing
import (
"reflect"
"testing"
"gitea.maximumdirect.net/eric/weatherreporter/internal/weatherdata"
2026-08-13 01:52:11 +00:00
)
func TestPreparedIdentityCopiesMutableFields(t *testing.T) {
2026-08-13 01:52:11 +00:00
moduleContext := testModuleContext()
context := BuildContext{
Resolved: moduleContext.Resolved,
Bundle: moduleContext.Collected.Bundle(),
Units: moduleContext.Units,
Timezone: moduleContext.Timezone,
Location: moduleContext.Location,
}
identity := BuildPreparedIdentity(context)
originalWarnings := append([]weatherdata.SourceWarning(nil), moduleContext.Collected.SourceWarnings...)
identity.Location.Name = "consumer mutation"
identity.SourceWarnings = append(identity.SourceWarnings, moduleContext.Collected.SourceWarnings[0])
if moduleContext.Location.Name == "consumer mutation" || !reflect.DeepEqual(moduleContext.Collected.SourceWarnings, originalWarnings) {
t.Fatalf("prepared identity changed its source context: %#v", identity)
2026-08-13 01:52:11 +00:00
}
}