Ejemplo n.º 1
0
func Test_parseAuctionApiResult(t *testing.T) {
	assert := wcg.NewAssert(t)

	file, _ := os.Open("./auction-sample.xml")
	defer file.Close()
	auction, err := parseAuctionApiResult(file)
	assert.Nil(err, "parseAuctionApiResult should not return an error")
	assert.EqStr("h206483716", auction.Id, "Id")
	assert.EqStr("9/20 モーニング娘。15 座間 秋ツアー 夜公演 一般席 即決特典付", auction.Title, "Title")
	assert.EqStr("http://page8.auctions.yahoo.co.jp/jp/auction/h206483716", auction.Url, "Url")
	assert.EqStr("", auction.ImageUrl, "ImageUrl")
	assert.EqStr("gaba9tmcy2gam0", auction.Seller, "Seller")
	assert.EqFloat32(9000.0, auction.InitPrice, "InitPrice")
	assert.EqFloat32(9500.0, auction.CurrentPrice, "CurrentPrice")
	assert.EqFloat32(13000.0, auction.BidOrBuy, "BidOrBuy")
	assert.EqFloat32(13000.0, auction.BidOrBuy, "BidOrBuy")
	assert.EqInt(1, auction.Quantity, "Quantity")
	assert.EqInt(3, auction.Bids, "Bids")
	assert.EqTime(
		wcg.Must(time.Parse(time.RFC3339, "2015-08-30T20:27:57+09:00")).(time.Time),
		auction.StartAt,
		"StartAt",
	)
	assert.EqTime(
		wcg.Must(time.Parse(time.RFC3339, "2015-08-31T23:27:57+09:00")).(time.Time),
		auction.EndAt,
		"EndAt",
	)
	assert.Ok(
		STATUS_CLOSED == auction.Status,
		"Closed",
	)
}
Ejemplo n.º 2
0
func (iepg *IEpg) ToTvRecord() *TvRecord {
	return &TvRecord{
		Id:        wcg.Must(wcg.UUID()).(string),
		Title:     strings.Replace(iepg.ProgramTitle, "/", "/", -1),
		Category:  iepg.Category,
		StartAt:   iepg.StartAt,
		EndAt:     iepg.EndAt,
		Cid:       iepg.Cid,
		Sid:       iepg.Sid,
		Uid:       "", // for future use.
		IEpgId:    iepg.Id,
		CreatedAt: iepg.CreatedAt,
		UpdatedAt: iepg.UpdatedAt,
	}
}
Ejemplo n.º 3
0
func NewTvRecord(title string, category string, start time.Time, end time.Time,
	cid string, sid string, uid string) *TvRecord {
	r := &TvRecord{
		Id:       wcg.Must(wcg.UUID()).(string),
		Title:    title,
		Category: category,
		StartAt:  start,
		EndAt:    end,
		Cid:      cid,
		Sid:      sid,
		Uid:      uid,
	}
	now := time.Now()
	r.CreatedAt = now
	r.UpdatedAt = now
	return r
}