e4f7c4a04c
- Introduced `mapper_test.go` to validate the functionality of backfilling notice location details from the buyer organization. - Implemented two test cases: one to ensure the location fields are correctly populated from the buyer when they are empty, and another to verify that existing values are not overwritten. - Enhanced the `mapper.go` file by adding the `backfillNoticeLocationFromBuyer` function to facilitate this logic. This update improves the reliability of notice data handling within the tender management system by ensuring accurate location information is maintained.
65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
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)
|
|
}
|
|
}
|