Skip to content

Commit

Permalink
test: find alpha2 by currency
Browse files Browse the repository at this point in the history
  • Loading branch information
perriea committed Jul 19, 2022
1 parent 33d4a30 commit 2668ac8
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,3 +397,40 @@ func TestFindCountryByCallingCode(t *testing.T) {
})
}
}

func TestFindCountriesByCurrency(t *testing.T) {
tests := []struct {
name string
currency string
expectedError error
expectedCountry int
}{
{
name: "Find countries by valid currency should return countries when currency is present for countries",
currency: "EUR",
expectedError: nil,
expectedCountry: 34,
},
{
name: "Find countries by unknown country code should return error when searching countries",
currency: "ERT",
expectedError: fmt.Errorf("gountries error. Could not find countries with currency name: ERT"),
expectedCountry: 0,
},
{
name: "Find countries by invalid currency length code should return error when searching countries",
currency: "CNYE",
expectedError: fmt.Errorf("gountries error. Invalid currency format: CNYE"),
expectedCountry: 0,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
actualCountry, actualError := query.FindCountriesByCurrency(test.currency)
if !(reflect.DeepEqual(test.expectedCountry, len(actualCountry)) &&
reflect.DeepEqual(test.expectedError, actualError)) {
t.Fail()
}
})
}
}

0 comments on commit 2668ac8

Please sign in to comment.