Skip to content
This repository has been archived by the owner on Jul 20, 2024. It is now read-only.

Commit

Permalink
adds tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nf1s committed Mar 22, 2020
1 parent b2e7d57 commit 7aa8d3b
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 1 deletion.
26 changes: 25 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

92 changes: 92 additions & 0 deletions covid_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package main

import (
"go-covid/covid"
"testing"
"github.com/stretchr/testify/assert"

)

var _int int
var _string string
var _float float64

func TestGetCountryByName(t *testing.T) {

data := covid.GetCountryByName("italy")

assert.IsType(t,_int,data.Attrs.Id)
assert.IsType(t,_string,data.Attrs.Country)
assert.IsType(t,_int,data.Attrs.LastUpdate)
assert.IsType(t,_int,data.Attrs.Confirmed)
assert.IsType(t,_int,data.Attrs.Deaths)
assert.IsType(t,_int,data.Attrs.Active)

assert.IsType(t,_int,data.Attrs.Recovered)
assert.IsType(t,_float,data.Attrs.Latitude)
assert.IsType(t,_float,data.Attrs.Longitude)
assert.Equal(t, "Italy", data.Attrs.Country)

}

func TestGetCountryById(t *testing.T) {


data := covid.GetCountryById(50)
assert.IsType(t,_int,data.Attrs.Id)
assert.IsType(t,_string,data.Attrs.Country)
assert.IsType(t,_int,data.Attrs.LastUpdate)
assert.IsType(t,_int,data.Attrs.Confirmed)
assert.IsType(t,_int,data.Attrs.Deaths)
assert.IsType(t,_int,data.Attrs.Active)
assert.IsType(t,_int,data.Attrs.Recovered)
assert.IsType(t,_float,data.Attrs.Latitude)
assert.IsType(t,_float,data.Attrs.Longitude)

}

func TestGetAll(t *testing.T) {

all_data := covid.GetData()
data := all_data[0]
assert.IsType(t,_int,data.Attrs.Id)
assert.IsType(t,_string,data.Attrs.Country)
assert.IsType(t,_int,data.Attrs.LastUpdate)
assert.IsType(t,_int,data.Attrs.Confirmed)
assert.IsType(t,_int,data.Attrs.Deaths)
assert.IsType(t,_int,data.Attrs.Active)
assert.IsType(t,_int,data.Attrs.Recovered)
assert.IsType(t,_float,data.Attrs.Latitude)
assert.IsType(t,_float,data.Attrs.Longitude)

}

func ListCountries(t *testing.T) {
data := covid.ListCountries()
country := data[0]
assert.IsType(t,_int,country.Attrs.Id)
assert.IsType(t,_string,country.Attrs.Name)
}

func TestGetTotalActive(t *testing.T) {
result := covid.GetTotalActive()
assert.IsType(t,_int,result)

}
func TestGetTotalConfirmed(t *testing.T) {
result := covid.GetTotalConfirmed()
assert.IsType(t,_int,result)

}

func TestGetTotalRecovered(t *testing.T) {
result := covid.GetTotalRecovered()
assert.IsType(t,_int,result)

}

func TestGetTotalDeaths(t *testing.T) {
result := covid.GetTotalDeaths()
assert.IsType(t,_int,result)

}

0 comments on commit 7aa8d3b

Please sign in to comment.