github.com/wtfutil/wtf@v0.43.0/modules/covid/cases_test.go (about)

     1  package covid
     2  
     3  import (
     4  	"encoding/json"
     5  	"testing"
     6  )
     7  
     8  func Test_CasesInclude(t *testing.T) {
     9  	// The api does not seem to return the correct recovered numbers
    10  	responseBody := `{"latest":{"confirmed":3093619,"deaths":73018,"recovered":0},"locations":[]}`
    11  	latestData := Cases{}
    12  	_ = json.Unmarshal([]byte(responseBody), &latestData)
    13  	expectedConfirmed := 3093619
    14  	expectedDeaths := 73018
    15  	actualConfirmed := latestData.Latest.Confirmed
    16  	actualDeaths := latestData.Latest.Deaths
    17  
    18  	if expectedConfirmed != actualConfirmed {
    19  		t.Errorf("\nexpected: %v\n     got: %v", expectedConfirmed, actualConfirmed)
    20  	}
    21  	if expectedDeaths != actualDeaths {
    22  		t.Errorf("\nexpected: %v\n     got: %v", expectedDeaths, actualDeaths)
    23  	}
    24  }