File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -397,3 +397,40 @@ func TestFindCountryByCallingCode(t *testing.T) {
397397 })
398398 }
399399}
400+
401+ func TestFindCountriesByCurrency (t * testing.T ) {
402+ tests := []struct {
403+ name string
404+ currency string
405+ expectedError error
406+ expectedCountry int
407+ }{
408+ {
409+ name : "Find countries by valid currency should return countries when currency is present for countries" ,
410+ currency : "EUR" ,
411+ expectedError : nil ,
412+ expectedCountry : 34 ,
413+ },
414+ {
415+ name : "Find countries by unknown country code should return error when searching countries" ,
416+ currency : "ERT" ,
417+ expectedError : fmt .Errorf ("gountries error. Could not find countries with currency name: ERT" ),
418+ expectedCountry : 0 ,
419+ },
420+ {
421+ name : "Find countries by invalid currency length code should return error when searching countries" ,
422+ currency : "CNYE" ,
423+ expectedError : fmt .Errorf ("gountries error. Invalid currency format: CNYE" ),
424+ expectedCountry : 0 ,
425+ },
426+ }
427+ for _ , test := range tests {
428+ t .Run (test .name , func (t * testing.T ) {
429+ actualCountry , actualError := query .FindCountriesByCurrency (test .currency )
430+ if ! (reflect .DeepEqual (test .expectedCountry , len (actualCountry )) &&
431+ reflect .DeepEqual (test .expectedError , actualError )) {
432+ t .Fail ()
433+ }
434+ })
435+ }
436+ }
You can’t perform that action at this time.
0 commit comments