package model import ( "testing" "gorm.io/datatypes" ) func TestContactSyncLocationAndCountryCodePrefersISOCode(t *testing.T) { contact := Contact{ AdditionalAttributes: datatypes.JSON([]byte(`{"city":"贵州贵阳","country":"China","country_code":"CN"}`)), } contact.syncLocationAndCountryCode() if contact.Location != "贵州贵阳" || contact.CountryCode != "CN" { t.Fatalf("location=%q country_code=%q", contact.Location, contact.CountryCode) } }