mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Update test (#1050)
This commit is contained in:
parent
f48b17269c
commit
6ecec4f149
24
modules/covid/cases_test.go
Normal file
24
modules/covid/cases_test.go
Normal 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)
|
||||
}
|
||||
}
|
@ -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")
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user