1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Update test (#1050)

This commit is contained in:
David Bouchare 2021-01-25 05:49:10 +01:00 committed by GitHub
parent f48b17269c
commit 6ecec4f149
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 31 deletions

View File

@ -0,0 +1,24 @@
package covid
import (
"encoding/json"
"testing"
)
func Test_CasesInclude(t *testing.T) {
// The api does not seem to return the correct recovered numbers
responseBody := `{"latest":{"confirmed":3093619,"deaths":73018,"recovered":0},"locations":[]}`
latestData := Cases{}
_ = json.Unmarshal([]byte(responseBody), &latestData)
expectedConfirmed := 3093619
expectedDeaths := 73018
actualConfirmed := latestData.Latest.Confirmed
actualDeaths := latestData.Latest.Deaths
if expectedConfirmed != actualConfirmed {
t.Errorf("\nexpected: %v\n got: %v", expectedConfirmed, actualConfirmed)
}
if expectedDeaths != actualDeaths {
t.Errorf("\nexpected: %v\n got: %v", expectedDeaths, actualDeaths)
}
}

View File

@ -1,31 +0,0 @@
package covid
import (
"testing"
)
func TestLatestCases(t *testing.T) {
latestCasesToAssert, err := LatestCases()
if err != nil {
t.Error("LatestCases() returned an error")
}
if latestCasesToAssert.Latest.Confirmed == 0 {
t.Error("LatestCases() should return a non 0 integer")
}
}
func (widget *Widget) TestCountryCases(t *testing.T) {
countryList := []string{"US", "FR"}
c := make([]interface{}, len(countryList))
for i, v := range countryList {
c[i] = v
}
latestCountryCasesToAssert, err := widget.LatestCountryCases(c)
if err != nil {
t.Error("LatestCountryCases() returned an error")
}
if len(latestCountryCasesToAssert) == 0 {
t.Error("LatestCountryCases() should not be empty")
}
}