@@ -14,6 +14,7 @@ type processGeofeedTest struct {
1414 c CheckResult
1515 em error
1616 laxMode bool
17+ emptyOK bool
1718}
1819
1920func TestProcessGeofeed_Valid (t * testing.T ) {
@@ -74,14 +75,31 @@ func TestProcessGeofeed_Valid(t *testing.T) {
7475 },
7576 laxMode : false ,
7677 },
78+ {
79+ gf : "test_data/empty.csv" ,
80+ db : "test_data/GeoIP2-City-Test.mmdb" ,
81+ c : CheckResult {
82+ Total : 0 ,
83+ SampleInvalidRows : map [RowInvalidity ]string {},
84+ },
85+ emptyOK : true ,
86+ },
7787 }
7888
7989 // Testing the full content of the difference explanation strings is likely to be
8090 // tedious and brittle, so we will just check for some substrings.
8191 for _ , test := range goodTests {
8292 t .Run (
8393 test .gf + " " + test .db , func (t * testing.T ) {
84- c , dl , _ , err := ProcessGeofeed (test .gf , test .db , "" , Options {LaxMode : test .laxMode })
94+ c , dl , _ , err := ProcessGeofeed (
95+ test .gf ,
96+ test .db ,
97+ "" ,
98+ Options {
99+ EmptyOK : test .emptyOK ,
100+ LaxMode : test .laxMode ,
101+ },
102+ )
85103 require .NoError (t , err , "processGeofeed ran without error" )
86104 for i , s := range test .dl {
87105 assert .Contains (
@@ -102,7 +120,6 @@ func TestProcessGeofeed_Invalid(t *testing.T) {
102120 {
103121 gf : "test_data/geofeed-invalid-missing-fields.csv" ,
104122 db : "test_data/GeoIP2-City-Test.mmdb" ,
105- dl : []string {},
106123 c : CheckResult {
107124 Total : 2 ,
108125 Differences : 0 ,
@@ -118,7 +135,6 @@ func TestProcessGeofeed_Invalid(t *testing.T) {
118135 {
119136 gf : "test_data/geofeed-invalid-empty-network.csv" ,
120137 db : "test_data/GeoIP2-City-Test.mmdb" ,
121- dl : []string {},
122138 c : CheckResult {
123139 Total : 2 ,
124140 Differences : 1 ,
@@ -133,7 +149,6 @@ func TestProcessGeofeed_Invalid(t *testing.T) {
133149 {
134150 gf : "test_data/geofeed-invalid-network.csv" ,
135151 db : "test_data/GeoIP2-City-Test.mmdb" ,
136- dl : []string {},
137152 c : CheckResult {
138153 Total : 2 ,
139154 Differences : 1 ,
@@ -149,7 +164,6 @@ func TestProcessGeofeed_Invalid(t *testing.T) {
149164 // Geofeed that is valid in lax mode should not be valid if laxMode == true.
150165 gf : "test_data/geofeed-valid-lax.csv" ,
151166 db : "test_data/GeoIP2-City-Test.mmdb" ,
152- dl : []string {},
153167 c : CheckResult {
154168 Total : 3 ,
155169 Differences : 1 ,
@@ -162,12 +176,30 @@ func TestProcessGeofeed_Invalid(t *testing.T) {
162176 em : ErrInvalidGeofeed ,
163177 laxMode : false ,
164178 },
179+ {
180+ gf : "test_data/empty.csv" ,
181+ db : "test_data/GeoIP2-City-Test.mmdb" ,
182+ c : CheckResult {
183+ Total : 0 ,
184+ SampleInvalidRows : map [RowInvalidity ]string {},
185+ },
186+ em : ErrEmptyGeofeed ,
187+ emptyOK : false ,
188+ },
165189 }
166190
167191 for _ , test := range badTests {
168192 t .Run (
169193 test .gf + " " + test .db , func (t * testing.T ) {
170- c , _ , _ , err := ProcessGeofeed (test .gf , test .db , "" , Options {LaxMode : test .laxMode })
194+ c , _ , _ , err := ProcessGeofeed (
195+ test .gf ,
196+ test .db ,
197+ "" ,
198+ Options {
199+ EmptyOK : test .emptyOK ,
200+ LaxMode : test .laxMode ,
201+ },
202+ )
171203 require .ErrorIs (
172204 t ,
173205 err ,
0 commit comments