2022-05-14 14:34:36 -07:00
|
|
|
package scraper_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
2023-07-30 14:19:07 -03:00
|
|
|
. "gitlab.com/offline-twitter/twitter_offline_engine/pkg/scraper"
|
2022-05-14 14:34:36 -07:00
|
|
|
)
|
|
|
|
|
2023-08-18 18:59:15 -03:00
|
|
|
func TestFormatSpaceDuration(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
s := Space{
|
2023-08-19 22:35:10 -03:00
|
|
|
StartedAt: TimestampFromUnix(1000),
|
|
|
|
EndedAt: TimestampFromUnix(5000),
|
2023-08-18 18:59:15 -03:00
|
|
|
}
|
|
|
|
assert.Equal(s.FormatDuration(), "1h06m")
|
|
|
|
|
2023-08-19 22:35:10 -03:00
|
|
|
s.EndedAt = TimestampFromUnix(500000)
|
2023-08-18 18:59:15 -03:00
|
|
|
assert.Equal(s.FormatDuration(), "138h36m")
|
|
|
|
|
2023-08-19 22:35:10 -03:00
|
|
|
s.EndedAt = TimestampFromUnix(1005)
|
2023-08-18 18:59:15 -03:00
|
|
|
assert.Equal(s.FormatDuration(), "0m05s")
|
|
|
|
}
|