package briefing import ( "reflect" "testing" "gitea.maximumdirect.net/eric/weatherreporter/internal/weatherdata" ) func TestPreparedIdentityCopiesMutableFields(t *testing.T) { 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) } }