Skip to content

Commit

Permalink
Merge pull request bsm#30 from Proxeter/remove_check_empty_assets
Browse files Browse the repository at this point in the history
Removed check for empty assets to support another formats like onclick with openrtb format
  • Loading branch information
dim authored Feb 28, 2017
2 parents a962edc + d08d760 commit e402fab
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 6 deletions.
1 change: 0 additions & 1 deletion bidrequest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ var _ = Describe("BidRequest", func() {
Expect((&BidRequest{}).Validate()).To(Equal(ErrInvalidReqNoID))
Expect((&BidRequest{ID: "A"}).Validate()).To(Equal(ErrInvalidReqNoImps))
Expect((&BidRequest{ID: "A", Imp: []Impression{{ID: "1"}}, Site: &Site{}, App: &App{}}).Validate()).To(Equal(ErrInvalidReqMultiInv))
Expect((&BidRequest{ID: "A", Imp: []Impression{{ID: "1"}}}).Validate()).To(Equal(ErrInvalidImpNoAssets))

Expect((&BidRequest{ID: "A", Imp: []Impression{{ID: "1", Banner: &Banner{}}}}).Validate()).NotTo(HaveOccurred())
Expect((&BidRequest{ID: "A", Imp: []Impression{{ID: "1", Banner: &Banner{}}}, Site: &Site{}}).Validate()).NotTo(HaveOccurred())
Expand Down
5 changes: 1 addition & 4 deletions impression.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import "errors"
// Validation errors
var (
ErrInvalidImpNoID = errors.New("openrtb: impression ID missing")
ErrInvalidImpNoAssets = errors.New("openrtb: impression has no assets") // neither Banner, nor Video, nor Native
ErrInvalidImpMultiAssets = errors.New("openrtb: impression has multiple assets") // at least two out of Banner, Video, Native
)

Expand Down Expand Up @@ -55,9 +54,7 @@ func (imp *Impression) Validate() error {
return ErrInvalidImpNoID
}

if count := imp.assetCount(); count == 0 {
return ErrInvalidImpNoAssets
} else if count > 1 {
if count := imp.assetCount(); count > 1 {
return ErrInvalidImpMultiAssets
}

Expand Down
1 change: 0 additions & 1 deletion impression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ var _ = Describe("Impression", func() {

It("should validate", func() {
Expect((&Impression{}).Validate()).To(Equal(ErrInvalidImpNoID))
Expect((&Impression{ID: "IMPID"}).Validate()).To(Equal(ErrInvalidImpNoAssets))
Expect((&Impression{ID: "IMPID", Banner: &Banner{}, Video: &Video{}}).Validate()).To(Equal(ErrInvalidImpMultiAssets))
Expect((&Impression{ID: "IMPID", Banner: &Banner{}}).Validate()).NotTo(HaveOccurred())
})
Expand Down

0 comments on commit e402fab

Please sign in to comment.