us-dop-scrapper/wait/wait_test.go

41 lines
810 B
Go

package wait
import (
"testing"
"time"
)
func TestWaitAmount(t *testing.T) {
type cases struct {
name string
initDate time.Time
infoAmount float64
longAmount float64
}
scenario := []cases{
{
name: "success/3h",
initDate: time.Now().Add(-1 * time.Hour),
infoAmount: 24,
longAmount: 24,
},
{
name: "success/now",
initDate: time.Now(),
infoAmount: 24,
longAmount: 24,
},
}
for _, tt := range scenario {
t.Run(tt.name, func(t *testing.T) {
info, long := WaitAmount(tt.initDate)
if info.Hours() == 0 {
t.Errorf("wanted: %f got: %f, time: %v", tt.infoAmount, info.Hours(), tt.initDate.UTC())
}
if long.Hours() == 0 {
t.Errorf("wanted: %f got: %f, time: %v", tt.longAmount, long.Hours(), tt.initDate.UTC())
}
})
}
}