package ted import ( "testing" "tm/internal/notice" ) func TestBackfillNoticeLocationFromBuyer(t *testing.T) { n := ¬ice.Notice{ BuyerOrganization: ¬ice.Organization{ Address: notice.Address{ CountryCode: "POL", CityName: "Warsaw", PostalZone: "00-001", CountrySubentityCode: "PL14", }, }, } backfillNoticeLocationFromBuyer(n) if n.CountryCode != "POL" { t.Fatalf("expected country POL, got %q", n.CountryCode) } if n.CityName != "Warsaw" { t.Fatalf("expected city Warsaw, got %q", n.CityName) } if n.PostalCode != "00-001" { t.Fatalf("expected postal 00-001, got %q", n.PostalCode) } if n.RegionCode != "PL14" { t.Fatalf("expected region PL14, got %q", n.RegionCode) } } func TestBackfillNoticeLocationFromBuyerDoesNotOverwrite(t *testing.T) { n := ¬ice.Notice{ CountryCode: "DEU", CityName: "Berlin", PostalCode: "10115", RegionCode: "DE300", BuyerOrganization: ¬ice.Organization{ Address: notice.Address{ CountryCode: "POL", CityName: "Warsaw", PostalZone: "00-001", CountrySubentityCode: "PL14", }, }, } backfillNoticeLocationFromBuyer(n) if n.CountryCode != "DEU" { t.Fatalf("expected country DEU, got %q", n.CountryCode) } if n.CityName != "Berlin" { t.Fatalf("expected city Berlin, got %q", n.CityName) } if n.PostalCode != "10115" { t.Fatalf("expected postal 10115, got %q", n.PostalCode) } if n.RegionCode != "DE300" { t.Fatalf("expected region DE300, got %q", n.RegionCode) } }