able to parse xml
This commit is contained in:
@ -19,7 +19,7 @@ type Offer struct {
|
||||
PictureURLs []string `xml:"picture"`
|
||||
Vendor string `xml:"vendor"`
|
||||
Model string `xml:"model"`
|
||||
VendorCode int `xml:"vendorCode"`
|
||||
VendorCode string `xml:"vendorCode"`
|
||||
TypePrefix string `xml:"typePrefix"`
|
||||
Description string `xml:"description"`
|
||||
ManufacturerWarrany bool `xml:"manufacturer_warranty"`
|
||||
@ -33,7 +33,7 @@ type Currency struct {
|
||||
|
||||
type Category struct {
|
||||
ID int64 `xml:"id,attr"`
|
||||
ParentID int64 `xml:"parent_id,attr,omiempty"`
|
||||
ParentID int64 `xml:"parent_id,attr,omitempty"`
|
||||
Name string `xml:",chardata"`
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"encoding/xml"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/brianvoe/gofakeit/v6"
|
||||
)
|
||||
@ -12,12 +13,12 @@ func TestYMLSerialize(t *testing.T) {
|
||||
faker := gofakeit.New(0)
|
||||
|
||||
categories := make([]Category, faker.Rand.Intn(4))
|
||||
knownCategory := map[int]struct{}{}
|
||||
categoryIDs := make([]int, 0, 10)
|
||||
knownCategory := map[int64]struct{}{}
|
||||
categoryIDs := make([]int64, 0, 10)
|
||||
for i := range categories {
|
||||
categories[i].ID = faker.Rand.Int()
|
||||
categories[i].ID = faker.Int64()
|
||||
categories[i].Name = faker.HipsterWord()
|
||||
categories[i].ParentID = faker.Rand.Int()
|
||||
categories[i].ParentID = faker.Int64()
|
||||
|
||||
if _, ok := knownCategory[categories[i].ID]; ok {
|
||||
continue
|
||||
@ -42,7 +43,7 @@ func TestYMLSerialize(t *testing.T) {
|
||||
}
|
||||
offer.Vendor = faker.Company()
|
||||
offer.Model = faker.CarModel()
|
||||
offer.VendorCode = faker.Rand.Int()
|
||||
offer.VendorCode = faker.DigitN(8)
|
||||
offer.TypePrefix = faker.ProductName()
|
||||
offer.Description = faker.Sentence(12)
|
||||
offer.ManufacturerWarrany = true
|
||||
@ -68,7 +69,7 @@ func TestYMLSerialize(t *testing.T) {
|
||||
Categories: categories,
|
||||
Offers: offers,
|
||||
}
|
||||
catalog.Date = faker.Date()
|
||||
catalog.Date = faker.Date().Truncate(time.Second)
|
||||
|
||||
container := YmlContainer{
|
||||
YmlCatalog: catalog,
|
||||
|
||||
Reference in New Issue
Block a user