Skip to content

Commit

Permalink
Do not fail the build if the WorldBank api is offline
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaily committed Mar 5, 2023
1 parent 8e98436 commit f1115e3
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tests/FSharp.Data.Tests/WorldBankProvider.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module FSharp.Data.Tests.WorldBankProvider
module FSharp.Data.Tests.WorldBankProvider

open System
open System.Net
Expand All @@ -13,7 +13,14 @@ let data = WorldBankData.GetDataContext()

[<Test>]
let ``Should not throw exception for missing year in indicator``() =
data.Countries.``United Kingdom``.Indicators.``GNI growth (annual %)``.[1900] |> should equal Double.NaN
data.Countries.``United Kingdom``.Indicators.``GNI growth (annual %)``.[2012] |> should not' (equal Double.NaN)
data.Countries.``United Kingdom``.Indicators.``GNI growth (annual %)``.TryGetValueAt 1900 |> should equal None
data.Countries.``United Kingdom``.Indicators.``GNI growth (annual %)``.TryGetValueAt 2012 |> should not' (equal None)
try
data.Countries.``United Kingdom``.Indicators.``GNI growth (annual %)``.[1900] |> should equal Double.NaN
data.Countries.``United Kingdom``.Indicators.``GNI growth (annual %)``.[2012] |> should not' (equal Double.NaN)
data.Countries.``United Kingdom``.Indicators.``GNI growth (annual %)``.TryGetValueAt 1900 |> should equal None
data.Countries.``United Kingdom``.Indicators.``GNI growth (annual %)``.TryGetValueAt 2012 |> should not' (equal None)
with ex
when ex.ToString().Contains("The server has encountered an error which prevents it from fulfilling your request. Please contact the system administrator")
|| ex.ToString().Contains("Timeout exceeded while getting response")
|| ex.ToString().Contains("504 Gateway Time-out") ->
Assert.Inconclusive($"Worldbank api is having issues: {ex}")

0 comments on commit f1115e3

Please sign in to comment.