diff --git a/.travis.yml b/.travis.yml index 6bb6951..6b30613 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,9 @@ language: go go: - - "1.14" - - "1.12" - "1.13" + - "1.14" + - "1.15" + - "1.16" script: - go test -timeout 30s github.com/prebid/go-gdpr/bitutils diff --git a/go.mod b/go.mod index 6138ccb..dc02dbc 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,7 @@ module github.com/prebid/go-gdpr go 1.13 -require github.com/buger/jsonparser v0.0.0-20180318095312-2cac668e8456 +require ( + github.com/buger/jsonparser v0.0.0-20180318095312-2cac668e8456 + github.com/stretchr/testify v1.7.0 +) diff --git a/go.sum b/go.sum index 1641e53..45257bf 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,12 @@ github.com/buger/jsonparser v0.0.0-20180318095312-2cac668e8456 h1:SnUWpAH4lEUoS86woR12h21VMUbDe+DYp88V646wwMI= github.com/buger/jsonparser v0.0.0-20180318095312-2cac668e8456/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/vendorlist2/eager-parsing.go b/vendorlist2/eager-parsing.go index b4c7af2..88b0acf 100644 --- a/vendorlist2/eager-parsing.go +++ b/vendorlist2/eager-parsing.go @@ -25,9 +25,6 @@ func ParseEagerly(data []byte) (api.VendorList, error) { if contract.Version == 0 { return nil, errors.New("data.vendorListVersion was 0 or undefined. Versions should start at 1") } - if len(contract.Vendors) == 0 { - return nil, errors.New("data.vendors was undefined or had no elements") - } parsedList := parsedVendorList{ version: contract.Version, diff --git a/vendorlist2/eager-parsing_test.go b/vendorlist2/eager-parsing_test.go index 7a4085e..b59306c 100644 --- a/vendorlist2/eager-parsing_test.go +++ b/vendorlist2/eager-parsing_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/prebid/go-gdpr/api" + "github.com/stretchr/testify/assert" ) func TestEagerlyParsedVendorList(t *testing.T) { @@ -15,3 +16,20 @@ func TestEagerlyParsedVendorList(t *testing.T) { return vendorList }) } + +func TestParseEagerlyVendorsEmpty(t *testing.T) { + vendorListJSON := ` +{ + "gvlSpecificationVersion": 2, + "vendorListVersion": 28, + "tcfPolicyVersion": 2, + "lastUpdated": "2020-03-05T16:05:29Z", + "vendors": { } +} +` + vendorList, err := ParseEagerly([]byte(vendorListJSON)) + + assert.NoError(t, err) + assert.Equal(t, vendorList.Version(), uint16(28)) + assert.Nil(t, vendorList.Vendor(0)) +}