diff --git a/main.go b/main.go index 075a7cf..e1debc8 100644 --- a/main.go +++ b/main.go @@ -21,7 +21,7 @@ type LastValues struct { Confirmed uint `json:"confirmed"` Deaths uint `json:"deaths"` Recovered uint `json:"recovered"` - UpdatedAt time.Time + // UpdatedAt time.Time XXX: move somewhere else } type response struct { @@ -62,7 +62,6 @@ func GetDataCOVID19(ctx context.Context) (*LastValues, error) { Confirmed: resp.Data.Confirmed, Deaths: resp.Data.Deaths, Recovered: resp.Data.Recovered, - UpdatedAt: time.Now(), } }() select { @@ -75,16 +74,6 @@ func GetDataCOVID19(ctx context.Context) (*LastValues, error) { } } -// CompareInfos ... -func CompareInfos(currentValues LastValues) bool { - if lastValues.Confirmed != currentValues.Confirmed || - lastValues.Deaths != currentValues.Deaths || - lastValues.Recovered != currentValues.Recovered { - return true - } - return false -} - func routine(duration time.Duration) { const timeout = time.Second * 2 for ctx, cancel := context.WithTimeout(context.Background(), timeout); ; cancel() { @@ -93,7 +82,7 @@ func routine(duration time.Duration) { panic(err) } - if CompareInfos(*currentValue) { + if lastValues == *currentValue { err := beeep.Alert("COVID-19 Brazil", currentValue.String(), IMG) if err != nil { panic(err) diff --git a/main_test.go b/main_test.go index f2df944..94bb0d3 100644 --- a/main_test.go +++ b/main_test.go @@ -2,44 +2,8 @@ package main import ( "testing" - "time" ) -func TestCompareInfos(t *testing.T) { - lastValues := &LastValues{ - Confirmed: 1, - Deaths: 0, - Recovered: 0, - UpdatedAt: time.Now(), - } - type args struct { - currentValues LastValues - } - tests := []struct { - name string - args args - want bool - }{ - { - name: "Test Compare Infos returns true", - args: args{currentValues: *lastValues}, - want: true, - }, - { - name: "Test Compare Infos returns false", - args: args{currentValues: LastValues{}}, - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := CompareInfos(tt.args.currentValues); got != tt.want { - t.Errorf("CompareInfos() = %v, want %v", got, tt.want) - } - }) - } -} - func TestLastValues_String(t *testing.T) { type fields struct { Confirmed uint